summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libffmpeg/diff_to_ffmpeg_cvs.txt324
-rw-r--r--src/libffmpeg/libavcodec/4xm.c7
-rw-r--r--src/libffmpeg/libavcodec/Makefile.am21
-rw-r--r--src/libffmpeg/libavcodec/adpcm.c831
-rw-r--r--src/libffmpeg/libavcodec/adx.c407
-rw-r--r--src/libffmpeg/libavcodec/alpha/asm.h79
-rw-r--r--src/libffmpeg/libavcodec/alpha/dsputil_alpha.c6
-rw-r--r--src/libffmpeg/libavcodec/alpha/mpegvideo_alpha.c1
-rw-r--r--src/libffmpeg/libavcodec/armv4l/dsputil_arm.c25
-rw-r--r--src/libffmpeg/libavcodec/asv1.c667
-rw-r--r--src/libffmpeg/libavcodec/avcodec.c172
-rw-r--r--src/libffmpeg/libavcodec/avcodec.h343
-rw-r--r--src/libffmpeg/libavcodec/cabac.c206
-rw-r--r--src/libffmpeg/libavcodec/cabac.h381
-rw-r--r--src/libffmpeg/libavcodec/cinepak.c460
-rw-r--r--src/libffmpeg/libavcodec/common.c37
-rw-r--r--src/libffmpeg/libavcodec/common.h61
-rw-r--r--src/libffmpeg/libavcodec/dpcm.c245
-rw-r--r--src/libffmpeg/libavcodec/dsputil.c21
-rw-r--r--src/libffmpeg/libavcodec/dsputil.h19
-rw-r--r--src/libffmpeg/libavcodec/dv.c708
-rw-r--r--src/libffmpeg/libavcodec/dvdata.h116
-rw-r--r--src/libffmpeg/libavcodec/error_resilience.c25
-rw-r--r--src/libffmpeg/libavcodec/golomb.h91
-rw-r--r--src/libffmpeg/libavcodec/h263.c804
-rw-r--r--src/libffmpeg/libavcodec/h263data.h40
-rw-r--r--src/libffmpeg/libavcodec/h263dec.c131
-rw-r--r--src/libffmpeg/libavcodec/h264.c134
-rw-r--r--src/libffmpeg/libavcodec/h264data.h4
-rw-r--r--src/libffmpeg/libavcodec/huffyuv.c89
-rw-r--r--src/libffmpeg/libavcodec/i386/dsputil_mmx.c58
-rw-r--r--src/libffmpeg/libavcodec/i386/motion_est_mmx.c2
-rw-r--r--src/libffmpeg/libavcodec/i386/mpegvideo_mmx_template.c4
-rw-r--r--src/libffmpeg/libavcodec/i386/simple_idct_mmx.c7
-rw-r--r--src/libffmpeg/libavcodec/idcinvideo.c283
-rw-r--r--src/libffmpeg/libavcodec/imgconvert.c97
-rw-r--r--src/libffmpeg/libavcodec/imgconvert_template.h47
-rw-r--r--src/libffmpeg/libavcodec/imgresample.c42
-rw-r--r--src/libffmpeg/libavcodec/indeo3.c45
-rw-r--r--src/libffmpeg/libavcodec/indeo3data.h6
-rw-r--r--src/libffmpeg/libavcodec/interplayvideo.c976
-rw-r--r--src/libffmpeg/libavcodec/libpostproc/postprocess.c92
-rw-r--r--src/libffmpeg/libavcodec/libpostproc/postprocess_template.c141
-rw-r--r--src/libffmpeg/libavcodec/mdec.c276
-rw-r--r--src/libffmpeg/libavcodec/mjpeg.c873
-rw-r--r--src/libffmpeg/libavcodec/mlib/dsputil_mlib.c10
-rw-r--r--src/libffmpeg/libavcodec/motion_est.c63
-rw-r--r--src/libffmpeg/libavcodec/motion_est_template.c2
-rw-r--r--src/libffmpeg/libavcodec/mpeg12.c551
-rw-r--r--src/libffmpeg/libavcodec/mpeg12data.h36
-rw-r--r--src/libffmpeg/libavcodec/mpeg4data.h30
-rw-r--r--src/libffmpeg/libavcodec/mpegaudiodec.c274
-rw-r--r--src/libffmpeg/libavcodec/mpegvideo.c827
-rw-r--r--src/libffmpeg/libavcodec/mpegvideo.h37
-rw-r--r--src/libffmpeg/libavcodec/msmpeg4.c29
-rw-r--r--src/libffmpeg/libavcodec/msrle.c219
-rw-r--r--src/libffmpeg/libavcodec/msvideo1.c378
-rw-r--r--src/libffmpeg/libavcodec/opts.c22
-rw-r--r--src/libffmpeg/libavcodec/pcm.c375
-rw-r--r--src/libffmpeg/libavcodec/ppc/dsputil_altivec.c115
-rw-r--r--src/libffmpeg/libavcodec/ppc/dsputil_ppc.c158
-rw-r--r--src/libffmpeg/libavcodec/ppc/dsputil_ppc.h143
-rw-r--r--src/libffmpeg/libavcodec/ppc/fft_altivec.c10
-rw-r--r--src/libffmpeg/libavcodec/ppc/gcc_fixes.h27
-rw-r--r--src/libffmpeg/libavcodec/ppc/gmc_altivec.c11
-rw-r--r--src/libffmpeg/libavcodec/ppc/idct_altivec.c20
-rw-r--r--src/libffmpeg/libavcodec/ppc/mpegvideo_altivec.c6
-rw-r--r--src/libffmpeg/libavcodec/ppc/mpegvideo_ppc.c2
-rw-r--r--src/libffmpeg/libavcodec/ra144.c2407
-rw-r--r--src/libffmpeg/libavcodec/ra144.h2426
-rw-r--r--src/libffmpeg/libavcodec/ra288.c184
-rw-r--r--src/libffmpeg/libavcodec/ra288.h203
-rw-r--r--src/libffmpeg/libavcodec/ratecontrol.c58
-rw-r--r--src/libffmpeg/libavcodec/rational.c61
-rw-r--r--src/libffmpeg/libavcodec/rational.h53
-rw-r--r--src/libffmpeg/libavcodec/roqvideo.c501
-rw-r--r--src/libffmpeg/libavcodec/rpza.c311
-rw-r--r--src/libffmpeg/libavcodec/rv10.c1
-rw-r--r--src/libffmpeg/libavcodec/sp5x.h330
-rw-r--r--src/libffmpeg/libavcodec/svq1.c21
-rw-r--r--src/libffmpeg/libavcodec/svq1_cb.h4
-rw-r--r--src/libffmpeg/libavcodec/utils.c157
-rw-r--r--src/libffmpeg/libavcodec/vcr1.c200
-rw-r--r--src/libffmpeg/libavcodec/vp3.c627
-rw-r--r--src/libffmpeg/libavcodec/vqavideo.c618
-rw-r--r--src/libffmpeg/libavcodec/wmadec.c117
-rw-r--r--src/libffmpeg/libavcodec/wmv2.c4
-rw-r--r--src/libffmpeg/libavcodec/xan.c820
-rw-r--r--src/libffmpeg/xine_decoder.c256
89 files changed, 16850 insertions, 5258 deletions
diff --git a/src/libffmpeg/diff_to_ffmpeg_cvs.txt b/src/libffmpeg/diff_to_ffmpeg_cvs.txt
index 627cb4750..f68156a78 100644
--- a/src/libffmpeg/diff_to_ffmpeg_cvs.txt
+++ b/src/libffmpeg/diff_to_ffmpeg_cvs.txt
@@ -1,19 +1,18 @@
-? ffmpeg-030211.patch
Index: libavcodec/common.h
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/common.h,v
-retrieving revision 1.87
-diff -u -r1.87 common.h
---- libavcodec/common.h 26 Mar 2003 10:39:34 -0000 1.87
-+++ libavcodec/common.h 26 Mar 2003 13:49:18 -0000
-@@ -178,11 +178,19 @@
+retrieving revision 1.106
+diff -u -u -r1.106 common.h
+--- libavcodec/common.h 20 Oct 2003 20:23:46 -0000 1.106
++++ libavcodec/common.h 21 Oct 2003 12:10:49 -0000
+@@ -184,11 +184,19 @@
# else
-# ifdef DEBUG
--# define dprintf(fmt,args...) printf(fmt, ## args)
+-# define dprintf(fmt,...) printf(fmt, __VA_ARGS__)
-# else
--# define dprintf(fmt,args...)
+-# define dprintf(fmt,...)
-# endif
+#if __GNUC__
+#ifdef DEBUG
@@ -34,10 +33,10 @@ diff -u -r1.87 common.h
Index: libavcodec/dsputil.h
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/dsputil.h,v
-retrieving revision 1.60
-diff -u -r1.60 dsputil.h
---- libavcodec/dsputil.h 15 Mar 2003 02:06:09 -0000 1.60
-+++ libavcodec/dsputil.h 26 Mar 2003 13:49:18 -0000
+retrieving revision 1.74
+diff -u -u -r1.74 dsputil.h
+--- libavcodec/dsputil.h 13 Oct 2003 17:27:30 -0000 1.74
++++ libavcodec/dsputil.h 21 Oct 2003 12:10:51 -0000
@@ -29,9 +29,14 @@
#include "common.h"
@@ -53,8 +52,8 @@ diff -u -r1.60 dsputil.h
-//#define DEBUG
/* dct code */
typedef short DCTELEM;
- //typedef int DCTELEM;
-@@ -310,21 +315,25 @@
+
+@@ -317,21 +322,25 @@
#undef emms_c
@@ -80,13 +79,106 @@ diff -u -r1.60 dsputil.h
#define emms_c() \
+Index: libavcodec/fastmemcpy.h
+===================================================================
+RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/fastmemcpy.h,v
+retrieving revision 1.1
+diff -u -u -r1.1 fastmemcpy.h
+--- libavcodec/fastmemcpy.h 2 Aug 2001 08:29:38 -0000 1.1
++++ libavcodec/fastmemcpy.h 21 Oct 2003 12:10:53 -0000
+@@ -1 +1,8 @@
+-#include "../libvo/fastmemcpy.h"
++#ifndef __FASTMEMCPY_H__
++#define __FASTMEMCPY_H__
++
++#include "xineutils.h"
++
++#define memcpy(a,b,c) xine_fast_memcpy(a,b,c)
++
++#endif
+Index: libavcodec/mjpeg.c
+===================================================================
+RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/mjpeg.c,v
+retrieving revision 1.78
+diff -u -u -r1.78 mjpeg.c
+--- libavcodec/mjpeg.c 20 Oct 2003 20:23:46 -0000 1.78
++++ libavcodec/mjpeg.c 21 Oct 2003 12:11:08 -0000
+@@ -1504,7 +1504,7 @@
+ 4bytes field_size
+ 4bytes field_size_less_padding
+ */
+- s->buggy_avid = 1;
++// s->buggy_avid = 1;
+ // if (s->first_picture)
+ // printf("mjpeg: workarounding buggy AVID\n");
+ s->interlace_polarity = get_bits(&s->gb, 8);
+Index: libavcodec/mpegvideo.c
+===================================================================
+RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/mpegvideo.c,v
+retrieving revision 1.291
+diff -u -u -r1.291 mpegvideo.c
+--- libavcodec/mpegvideo.c 20 Oct 2003 09:52:02 -0000 1.291
++++ libavcodec/mpegvideo.c 21 Oct 2003 12:11:17 -0000
+@@ -836,7 +836,9 @@
+ if (MPV_common_init(s) < 0)
+ return -1;
+
++#ifdef CONFIG_ENCODERS_FULL
+ ff_init_me(s);
++#endif
+
+ #ifdef CONFIG_ENCODERS
+ #ifdef CONFIG_RISKY
+@@ -1637,8 +1639,10 @@
+ if (s->out_format == FMT_MJPEG)
+ mjpeg_picture_trailer(s);
+
++#ifdef CONFIG_ENCODERS_FULL
+ if(s->flags&CODEC_FLAG_PASS1)
+ ff_write_pass1_stats(s);
++#endif
+
+ for(i=0; i<4; i++){
+ avctx->error[i] += s->current_picture_ptr->error[i];
+@@ -3362,6 +3366,7 @@
+ /* Estimate motion for every MB */
+ s->mb_intra=0; //for the rate distoration & bit compare functions
+ if(s->pict_type != I_TYPE){
++#ifdef CONFIG_ENCODERS_FULL
+ if(s->pict_type != B_TYPE){
+ if((s->avctx->pre_me && s->last_non_b_pict_type==I_TYPE) || s->avctx->pre_me==2){
+ s->me.pre_pass=1;
+@@ -3399,6 +3404,7 @@
+ ff_estimate_p_frame_motion(s, mb_x, mb_y);
+ }
+ }
++#endif
+ }else /* if(s->pict_type == I_TYPE) */{
+ /* I-Frame */
+ //FIXME do we need to zero them?
+@@ -3433,6 +3439,7 @@
+ //printf("Scene change detected, encoding as I Frame %d %d\n", s->current_picture.mb_var_sum, s->current_picture.mc_mb_var_sum);
+ }
+
++#ifdef CONFIG_ENCODERS_FULL
+ if(!s->umvplus){
+ if(s->pict_type==P_TYPE || s->pict_type==S_TYPE) {
+ s->f_code= ff_get_best_fcode(s, s->p_mv_table, MB_TYPE_INTER);
+@@ -3457,6 +3464,7 @@
+ ff_fix_long_b_mvs(s, s->b_bidir_back_mv_table, s->b_code, MB_TYPE_BIDIR);
+ }
+ }
++#endif
+
+ if (!s->fixed_qscale)
+ s->current_picture.quality = ff_rate_estimate_qscale(s);
Index: libavcodec/i386/cputest.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/i386/cputest.c,v
retrieving revision 1.8
-diff -u -r1.8 cputest.c
+diff -u -u -r1.8 cputest.c
--- libavcodec/i386/cputest.c 26 Nov 2002 16:26:58 -0000 1.8
-+++ libavcodec/i386/cputest.c 26 Mar 2003 13:49:19 -0000
++++ libavcodec/i386/cputest.c 21 Oct 2003 12:11:37 -0000
@@ -1,122 +1,13 @@
-/* Cpu detection code, extracted from mmx.h ((c)1997-99 by H. Dietz
- and R. Fisher). Converted to C and improved by Fabrice Bellard */
@@ -217,9 +309,9 @@ Index: libavcodec/i386/mmx.h
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/i386/mmx.h,v
retrieving revision 1.3
-diff -u -r1.3 mmx.h
+diff -u -u -r1.3 mmx.h
--- libavcodec/i386/mmx.h 27 May 2002 08:31:54 -0000 1.3
-+++ libavcodec/i386/mmx.h 26 Mar 2003 13:49:19 -0000
++++ libavcodec/i386/mmx.h 21 Oct 2003 12:11:38 -0000
@@ -1,243 +1 @@
-/*
- * mmx.h
@@ -465,13 +557,29 @@ diff -u -r1.3 mmx.h
-
-#endif /* AVCODEC_I386MMX_H */
+#include "xineutils.h"
+Index: libavcodec/i386/motion_est_mmx.c
+===================================================================
+RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/i386/motion_est_mmx.c,v
+retrieving revision 1.11
+diff -u -u -r1.11 motion_est_mmx.c
+--- libavcodec/i386/motion_est_mmx.c 9 Sep 2003 22:59:16 -0000 1.11
++++ libavcodec/i386/motion_est_mmx.c 21 Oct 2003 12:11:39 -0000
+@@ -26,7 +26,7 @@
+ 0x0002000200020002,
+ };
+
+-static __attribute__ ((aligned(8), unused)) uint64_t bone= 0x0101010101010101LL;
++static const __attribute__ ((aligned(8), unused)) uint64_t bone= 0x0101010101010101LL;
+
+ static inline void sad8_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h)
+ {
Index: libavcodec/libpostproc/postprocess.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/libpostproc/postprocess.c,v
-retrieving revision 1.83
-diff -u -r1.83 postprocess.c
---- libavcodec/libpostproc/postprocess.c 6 Mar 2003 13:51:18 -0000 1.83
-+++ libavcodec/libpostproc/postprocess.c 26 Mar 2003 13:49:20 -0000
+retrieving revision 1.90
+diff -u -u -r1.90 postprocess.c
+--- libavcodec/libpostproc/postprocess.c 14 Sep 2003 16:52:34 -0000 1.90
++++ libavcodec/libpostproc/postprocess.c 21 Oct 2003 12:11:40 -0000
@@ -70,8 +70,9 @@
#include "config.h"
#include <inttypes.h>
@@ -489,7 +597,7 @@ diff -u -r1.83 postprocess.c
//#undef ARCH_X86
//#define DEBUG_BRIGHTNESS
-#ifdef USE_FASTMEMCPY
--#include "libvo/fastmemcpy.h"
+-#include "../fastmemcpy.h"
-#endif
+
+#define memcpy(a,b,c) xine_fast_memcpy(a,b,c)
@@ -518,10 +626,13 @@ diff -u -r1.83 postprocess.c
#endif
-@@ -159,37 +160,6 @@
- }
- #endif
-
+@@ -156,37 +157,6 @@
+ static inline void unusedVariableWarningFixer()
+ {
+ if(w05 + w20 + b00 + b01 + b02 + b08 + b80 == 0) b00=0;
+-}
+-#endif
+-
-
-#ifdef ARCH_X86
-static inline void prefetchnta(void *p)
@@ -550,154 +661,17 @@ diff -u -r1.83 postprocess.c
- asm volatile( "prefetcht2 (%0)\n\t"
- : : "r" (p)
- );
--}
--#endif
--
- // The horizontal Functions exist only in C cuz the MMX code is faster with vertical filters and transposing
-
- /**
-Index: libavcodec/mjpeg.c
-===================================================================
-RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/mjpeg.c,v
-retrieving revision 1.61
-diff -u -r1.61 mjpeg.c
---- libavcodec/mjpeg.c 23 May 2003 16:04:24 -0000 1.61
-+++ libavcodec/mjpeg.c 23 May 2003 18:18:53 -0000
-@@ -1471,7 +1471,7 @@
- 4bytes field_size
- 4bytes field_size_less_padding
- */
-- s->buggy_avid = 1;
-+// s->buggy_avid = 1;
- // if (s->first_picture)
- // printf("mjpeg: workarounding buggy AVID\n");
- s->interlace_polarity = get_bits(&s->gb, 8);
-Index: libavcodec/mpegvideo.c
-===================================================================
-RCS file: /cvsroot/xine/xine-lib/src/libffmpeg/libavcodec/mpegvideo.c,v
-retrieving revision 1.31
-diff -u -r1.31 mpegvideo.c
---- libavcodec/mpegvideo.c 9 May 2003 23:54:05 -0000 1.31
-+++ libavcodec/mpegvideo.c 25 May 2003 18:29:52 -0000
-@@ -763,7 +763,9 @@
- if (MPV_common_init(s) < 0)
- return -1;
-
-+#ifdef CONFIG_ENCODERS_FULL
- ff_init_me(s);
-+#endif
-
- #ifdef CONFIG_ENCODERS
- #ifdef CONFIG_RISKY
-@@ -1550,8 +1552,10 @@
- if (s->out_format == FMT_MJPEG)
- mjpeg_picture_trailer(s);
-
-+#ifdef CONFIG_ENCODERS_FULL
- if(s->flags&CODEC_FLAG_PASS1)
- ff_write_pass1_stats(s);
-+#endif
-
- for(i=0; i<4; i++){
- avctx->error[i] += s->current_picture_ptr->error[i];
-@@ -3137,6 +3141,7 @@
- /* Estimate motion for every MB */
- s->mb_intra=0; //for the rate distoration & bit compare functions
- if(s->pict_type != I_TYPE){
-+#ifdef CONFIG_ENCODERS_FULL
- if(s->pict_type != B_TYPE){
- if((s->avctx->pre_me && s->last_non_b_pict_type==I_TYPE) || s->avctx->pre_me==2){
- s->me.pre_pass=1;
-@@ -3174,6 +3179,7 @@
- ff_estimate_p_frame_motion(s, mb_x, mb_y);
- }
- }
-+#endif
- }else /* if(s->pict_type == I_TYPE) */{
- /* I-Frame */
- //FIXME do we need to zero them?
-@@ -3208,6 +3214,7 @@
- //printf("Scene change detected, encoding as I Frame %d %d\n", s->current_picture.mb_var_sum, s->current_picture.mc_mb_var_sum);
- }
-
-+#ifdef CONFIG_ENCODERS_FULL
- if(!s->umvplus){
- if(s->pict_type==P_TYPE || s->pict_type==S_TYPE) {
- s->f_code= ff_get_best_fcode(s, s->p_mv_table, MB_TYPE_INTER);
-@@ -3232,6 +3239,7 @@
- ff_fix_long_b_mvs(s, s->b_bidir_back_mv_table, s->b_code, MB_TYPE_BIDIR);
- }
- }
-+#endif
-
- if (s->fixed_qscale)
- s->frame_qscale = s->current_picture.quality;
-Index: libavcodec/h263.c
-===================================================================
-RCS file: /cvsroot/xine/xine-lib/src/libffmpeg/libavcodec/h263.c,v
-retrieving revision 1.29
-diff -u -r1.29 h263.c
---- libavcodec/h263.c 19 Jun 2003 00:47:19 -0000 1.29
-+++ libavcodec/h263.c 27 Jun 2003 13:51:30 -0000
-@@ -4606,6 +4606,7 @@
- s->divx_version= ver;
- s->divx_build= build;
- s->divx_packed= e==3 && last=='p';
-+#if 0
- if(s->picture_number==0){
- printf("This file was encoded with DivX%d Build%d", ver, build);
- if(s->divx_packed)
-@@ -4613,6 +4614,7 @@
- else
- printf("\n");
- }
-+#endif
- }
-
- /* ffmpeg detection */
-@@ -4628,16 +4630,20 @@
- if(e==4){
- s->ffmpeg_version= ver*256*256 + ver2*256 + ver3;
- s->lavc_build= build;
-+#if 0
- if(s->picture_number==0)
- printf("This file was encoded with libavcodec build %d\n", build);
-+#endif
- }
-
- /* xvid detection */
- e=sscanf(buf, "XviD%d", &build);
- if(e==1){
- s->xvid_build= build;
-+#if 0
- if(s->picture_number==0)
- printf("This file was encoded with XviD build %d\n", build);
-+#endif
- }
-
- //printf("User Data: %s\n", buf);
-Index: libavcodec/i386/motion_est_mmx.c
-===================================================================
-RCS file: /cvsroot/xine/xine-lib/src/libffmpeg/libavcodec/i386/motion_est_mmx.c,v
-retrieving revision 1.8
-diff -u -r1.8 motion_est_mmx.c
---- libavcodec/i386/motion_est_mmx.c 26 Mar 2003 14:44:17 -0000 1.8
-+++ libavcodec/i386/motion_est_mmx.c 2 Jul 2003 14:31:19 -0000
-@@ -26,7 +26,7 @@
- 0x0002000200020002,
- };
-
--static __attribute__ ((aligned(8))) uint64_t bone= 0x0101010101010101LL;
-+static const __attribute__ ((aligned(8))) uint64_t bone= 0x0101010101010101LL;
+ }
+ #endif
- static inline void sad8_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h)
- {
Index: libavcodec/mlib/dsputil_mlib.c
===================================================================
-RCS file: /cvsroot/xine/xine-lib/src/libffmpeg/libavcodec/mlib/dsputil_mlib.c,v
---- dsputil_mlib,c 2003-10-19 13:06:27.560738000 +0100
-+++ dsputil_mlib.c 2003-10-19 13:01:50.427851000 +0100
-@@ -414,6 +414,7 @@
+RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/mlib/dsputil_mlib.c,v
+retrieving revision 1.14
+diff -u -u -r1.14 dsputil_mlib.c
+--- libavcodec/mlib/dsputil_mlib.c 11 Oct 2003 16:43:51 -0000 1.14
++++ libavcodec/mlib/dsputil_mlib.c 21 Oct 2003 12:11:42 -0000
+@@ -419,6 +419,7 @@
void dsputil_init_mlib(DSPContext* c, AVCodecContext *avctx)
{
@@ -705,7 +679,7 @@ RCS file: /cvsroot/xine/xine-lib/src/libffmpeg/libavcodec/mlib/dsputil_mlib.c,v
c->get_pixels = get_pixels_mlib;
c->diff_pixels = diff_pixels_mlib;
c->add_pixels_clamped = add_pixels_clamped_mlib;
-@@ -440,10 +441,12 @@
+@@ -445,10 +446,12 @@
c->put_no_rnd_pixels_tab[1][0] = put_pixels8_mlib;
c->bswap_buf = bswap_buf_mlib;
@@ -718,8 +692,8 @@ RCS file: /cvsroot/xine/xine-lib/src/libffmpeg/libavcodec/mlib/dsputil_mlib.c,v
if(s->avctx->dct_algo==FF_DCT_AUTO || s->avctx->dct_algo==FF_DCT_MLIB){
s->dsp.fdct = ff_fdct_mlib;
}
-@@ -453,4 +456,5 @@
- s->dsp.idct_add = ff_idct_add_mlib;
+@@ -459,4 +462,5 @@
+ s->dsp.idct = ff_idct_mlib;
s->dsp.idct_permutation_type= FF_NO_IDCT_PERM;
}
+ }
diff --git a/src/libffmpeg/libavcodec/4xm.c b/src/libffmpeg/libavcodec/4xm.c
index 80e87c379..03e4a175c 100644
--- a/src/libffmpeg/libavcodec/4xm.c
+++ b/src/libffmpeg/libavcodec/4xm.c
@@ -426,6 +426,11 @@ static inline void idct_put(FourXContext *f, int x, int y){
for(i=4; i<6; i++) idct(block[i]);
}
+/* Note transform is:
+y= ( 1b + 4g + 2r)/14
+cb=( 3b - 2g - 1r)/14
+cr=(-1b - 4g + 5r)/14
+*/
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
@@ -551,7 +556,7 @@ static int decode_i_frame(FourXContext *f, uint8_t *buf, int length){
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);
+ const int token_count __attribute__((unused)) = get32(buf + bitstream_size + 8);
int prestream_size= 4*get32(buf + bitstream_size + 4);
uint8_t *prestream= buf + bitstream_size + 12;
diff --git a/src/libffmpeg/libavcodec/Makefile.am b/src/libffmpeg/libavcodec/Makefile.am
index 7afe14737..87d234a17 100644
--- a/src/libffmpeg/libavcodec/Makefile.am
+++ b/src/libffmpeg/libavcodec/Makefile.am
@@ -18,8 +18,13 @@ noinst_LTLIBRARIES = libavcodec.la
libavcodec_la_SOURCES = \
4xm.c \
+ adpcm.c \
+ asv1.c \
+ cabac.c \
+ cinepak.c \
common.c \
cyuv.c \
+ dpcm.c \
dsputil.c \
dv.c \
error_resilience.c \
@@ -30,8 +35,10 @@ libavcodec_la_SOURCES = \
h263dec.c \
h264.c \
huffyuv.c \
+ idcinvideo.c \
imgconvert.c \
indeo3.c \
+ interplayvideo.c \
jfdctfst.c \
jfdctint.c \
jrevdct.c \
@@ -43,16 +50,25 @@ libavcodec_la_SOURCES = \
mpegaudiodec.c \
mpegvideo.c \
msmpeg4.c \
+ msrle.c \
+ msvideo1.c \
opts.c \
+ pcm.c \
ra144.c \
ra288.c \
ratecontrol.c \
+ rational.c \
+ roqvideo.c \
+ rpza.c \
rv10.c \
simple_idct.c \
svq1.c \
utils.c \
+ vcr1.c \
vp3.c \
- wmadec.c
+ vqavideo.c \
+ wmadec.c \
+ xan.c
libavcodec_la_LDFLAGS = \
$(top_builddir)/src/libffmpeg/libavcodec/armv4l/libavcodec_armv4l.la \
@@ -63,6 +79,7 @@ libavcodec_la_LDFLAGS = \
noinst_HEADERS = \
avcodec.h \
+ cabac.h \
common.h \
dsputil.h \
dvdata.h \
@@ -81,6 +98,8 @@ noinst_HEADERS = \
mpegvideo.h \
msmpeg4data.h \
os_support.h \
+ ra144.h \
+ ra288.h \
simple_idct.h \
svq1_cb.h \
svq1_vlc.h \
diff --git a/src/libffmpeg/libavcodec/adpcm.c b/src/libffmpeg/libavcodec/adpcm.c
new file mode 100644
index 000000000..a6ecaf543
--- /dev/null
+++ b/src/libffmpeg/libavcodec/adpcm.c
@@ -0,0 +1,831 @@
+/*
+ * ADPCM codecs
+ * Copyright (c) 2001-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"
+
+/**
+ * @file adpcm.c
+ * ADPCM codecs.
+ * First version by Francois Revol (revol@free.fr)
+ * Fringe ADPCM codecs (e.g., DK3, DK4, Westwood)
+ * by Mike Melanson (melanson@pcisys.net)
+ * CD-ROM XA ADPCM codec by BERO
+ *
+ * Features and limitations:
+ *
+ * Reference documents:
+ * http://www.pcisys.net/~melanson/codecs/simpleaudio.html
+ * http://www.geocities.com/SiliconValley/8682/aud3.txt
+ * http://openquicktime.sourceforge.net/plugins.htm
+ * XAnim sources (xa_codec.c) http://www.rasnaimaging.com/people/lapus/download.html
+ * http://www.cs.ucla.edu/~leec/mediabench/applications.html
+ * SoX source code http://home.sprynet.com/~cbagwell/sox.html
+ *
+ * CD-ROM XA:
+ * http://ku-www.ss.titech.ac.jp/~yatsushi/xaadpcm.html
+ * vagpack & depack http://homepages.compuserve.de/bITmASTER32/psx-index.html
+ * readstr http://www.geocities.co.jp/Playtown/2004/
+ */
+
+#define BLKSIZE 1024
+
+#define CLAMP_TO_SHORT(value) \
+if (value > 32767) \
+ value = 32767; \
+else if (value < -32768) \
+ value = -32768; \
+
+/* step_table[] and index_table[] are from the ADPCM reference source */
+/* This is the index table: */
+static const int index_table[16] = {
+ -1, -1, -1, -1, 2, 4, 6, 8,
+ -1, -1, -1, -1, 2, 4, 6, 8,
+};
+
+/**
+ * This is the step table. Note that many programs use slight deviations from
+ * this table, but such deviations are negligible:
+ */
+static const int step_table[89] = {
+ 7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
+ 19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
+ 50, 55, 60, 66, 73, 80, 88, 97, 107, 118,
+ 130, 143, 157, 173, 190, 209, 230, 253, 279, 307,
+ 337, 371, 408, 449, 494, 544, 598, 658, 724, 796,
+ 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066,
+ 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358,
+ 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899,
+ 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
+};
+
+/* These are for MS-ADPCM */
+/* AdaptationTable[], AdaptCoeff1[], and AdaptCoeff2[] are from libsndfile */
+static const int AdaptationTable[] = {
+ 230, 230, 230, 230, 307, 409, 512, 614,
+ 768, 614, 512, 409, 307, 230, 230, 230
+};
+
+static const int AdaptCoeff1[] = {
+ 256, 512, 0, 192, 240, 460, 392
+};
+
+static const int AdaptCoeff2[] = {
+ 0, -256, 0, 64, 0, -208, -232
+};
+
+/* These are for CD-ROM XA ADPCM */
+static const int xa_adpcm_table[5][2] = {
+ { 0, 0 },
+ { 60, 0 },
+ { 115, -52 },
+ { 98, -55 },
+ { 122, -60 }
+};
+
+/* end of tables */
+
+typedef struct ADPCMChannelStatus {
+ int predictor;
+ short int step_index;
+ int step;
+ /* for encoding */
+ int prev_sample;
+
+ /* MS version */
+ short sample1;
+ short sample2;
+ int coeff1;
+ int coeff2;
+ int idelta;
+} ADPCMChannelStatus;
+
+typedef struct ADPCMContext {
+ int channel; /* for stereo MOVs, decode left, then decode right, then tell it's decoded */
+ ADPCMChannelStatus status[2];
+ short sample_buffer[32]; /* hold left samples while waiting for right samples */
+} ADPCMContext;
+
+/* XXX: implement encoding */
+
+#ifdef CONFIG_ENCODERS
+static int adpcm_encode_init(AVCodecContext *avctx)
+{
+ if (avctx->channels > 2)
+ return -1; /* only stereo or mono =) */
+ switch(avctx->codec->id) {
+ case CODEC_ID_ADPCM_IMA_QT:
+ fprintf(stderr, "ADPCM: codec admcp_ima_qt unsupported for encoding !\n");
+ avctx->frame_size = 64; /* XXX: can multiple of avctx->channels * 64 (left and right blocks are interleaved) */
+ return -1;
+ break;
+ case CODEC_ID_ADPCM_IMA_WAV:
+ avctx->frame_size = (BLKSIZE - 4 * avctx->channels) * 8 / (4 * avctx->channels) + 1; /* each 16 bits sample gives one nibble */
+ /* and we have 4 bytes per channel overhead */
+ avctx->block_align = BLKSIZE;
+ /* seems frame_size isn't taken into account... have to buffer the samples :-( */
+ break;
+ case CODEC_ID_ADPCM_MS:
+ fprintf(stderr, "ADPCM: codec admcp_ms unsupported for encoding !\n");
+ return -1;
+ break;
+ default:
+ return -1;
+ break;
+ }
+
+ avctx->coded_frame= avcodec_alloc_frame();
+ avctx->coded_frame->key_frame= 1;
+
+ return 0;
+}
+
+static int adpcm_encode_close(AVCodecContext *avctx)
+{
+ av_freep(&avctx->coded_frame);
+
+ return 0;
+}
+
+
+static inline unsigned char adpcm_ima_compress_sample(ADPCMChannelStatus *c, short sample)
+{
+ int step_index;
+ unsigned char nibble;
+
+ int sign = 0; /* sign bit of the nibble (MSB) */
+ int delta, predicted_delta;
+
+ delta = sample - c->prev_sample;
+
+ if (delta < 0) {
+ sign = 1;
+ delta = -delta;
+ }
+
+ step_index = c->step_index;
+
+ /* nibble = 4 * delta / step_table[step_index]; */
+ nibble = (delta << 2) / step_table[step_index];
+
+ if (nibble > 7)
+ nibble = 7;
+
+ step_index += index_table[nibble];
+ if (step_index < 0)
+ step_index = 0;
+ if (step_index > 88)
+ step_index = 88;
+
+ /* what the decoder will find */
+ predicted_delta = ((step_table[step_index] * nibble) / 4) + (step_table[step_index] / 8);
+
+ if (sign)
+ c->prev_sample -= predicted_delta;
+ else
+ c->prev_sample += predicted_delta;
+
+ CLAMP_TO_SHORT(c->prev_sample);
+
+
+ nibble += sign << 3; /* sign * 8 */
+
+ /* save back */
+ c->step_index = step_index;
+
+ return nibble;
+}
+
+static int adpcm_encode_frame(AVCodecContext *avctx,
+ unsigned char *frame, int buf_size, void *data)
+{
+ int n;
+ short *samples;
+ unsigned char *dst;
+ ADPCMContext *c = avctx->priv_data;
+
+ dst = frame;
+ samples = (short *)data;
+/* n = (BLKSIZE - 4 * avctx->channels) / (2 * 8 * avctx->channels); */
+
+ switch(avctx->codec->id) {
+ case CODEC_ID_ADPCM_IMA_QT: /* XXX: can't test until we get .mov writer */
+ break;
+ case CODEC_ID_ADPCM_IMA_WAV:
+ n = avctx->frame_size / 8;
+ c->status[0].prev_sample = (signed short)samples[0]; /* XXX */
+/* c->status[0].step_index = 0; *//* XXX: not sure how to init the state machine */
+ *dst++ = (c->status[0].prev_sample) & 0xFF; /* little endian */
+ *dst++ = (c->status[0].prev_sample >> 8) & 0xFF;
+ *dst++ = (unsigned char)c->status[0].step_index;
+ *dst++ = 0; /* unknown */
+ samples++;
+ if (avctx->channels == 2) {
+ c->status[1].prev_sample = (signed short)samples[1];
+/* c->status[1].step_index = 0; */
+ *dst++ = (c->status[1].prev_sample) & 0xFF;
+ *dst++ = (c->status[1].prev_sample >> 8) & 0xFF;
+ *dst++ = (unsigned char)c->status[1].step_index;
+ *dst++ = 0;
+ samples++;
+ }
+
+ /* stereo: 4 bytes (8 samples) for left, 4 bytes for right, 4 bytes left, ... */
+ for (; n>0; n--) {
+ *dst = adpcm_ima_compress_sample(&c->status[0], samples[0]) & 0x0F;
+ *dst |= (adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels]) << 4) & 0xF0;
+ dst++;
+ *dst = adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 2]) & 0x0F;
+ *dst |= (adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 3]) << 4) & 0xF0;
+ dst++;
+ *dst = adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 4]) & 0x0F;
+ *dst |= (adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 5]) << 4) & 0xF0;
+ dst++;
+ *dst = adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 6]) & 0x0F;
+ *dst |= (adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 7]) << 4) & 0xF0;
+ dst++;
+ /* right channel */
+ if (avctx->channels == 2) {
+ *dst = adpcm_ima_compress_sample(&c->status[1], samples[1]);
+ *dst |= adpcm_ima_compress_sample(&c->status[1], samples[3]) << 4;
+ dst++;
+ *dst = adpcm_ima_compress_sample(&c->status[1], samples[5]);
+ *dst |= adpcm_ima_compress_sample(&c->status[1], samples[7]) << 4;
+ dst++;
+ *dst = adpcm_ima_compress_sample(&c->status[1], samples[9]);
+ *dst |= adpcm_ima_compress_sample(&c->status[1], samples[11]) << 4;
+ dst++;
+ *dst = adpcm_ima_compress_sample(&c->status[1], samples[13]);
+ *dst |= adpcm_ima_compress_sample(&c->status[1], samples[15]) << 4;
+ dst++;
+ }
+ samples += 8 * avctx->channels;
+ }
+ break;
+ default:
+ return -1;
+ }
+ return dst - frame;
+}
+#endif //CONFIG_ENCODERS
+
+static int adpcm_decode_init(AVCodecContext * avctx)
+{
+ ADPCMContext *c = avctx->priv_data;
+
+ c->channel = 0;
+ c->status[0].predictor = c->status[1].predictor = 0;
+ c->status[0].step_index = c->status[1].step_index = 0;
+ c->status[0].step = c->status[1].step = 0;
+
+ switch(avctx->codec->id) {
+ default:
+ break;
+ }
+ return 0;
+}
+
+static inline short adpcm_ima_expand_nibble(ADPCMChannelStatus *c, char nibble)
+{
+ int step_index;
+ int predictor;
+ int sign, delta, diff, step;
+
+ step = step_table[c->step_index];
+ step_index = c->step_index + index_table[(unsigned)nibble];
+ if (step_index < 0) step_index = 0;
+ else if (step_index > 88) step_index = 88;
+
+ sign = nibble & 8;
+ delta = nibble & 7;
+ /* perform direct multiplication instead of series of jumps proposed by
+ * the reference ADPCM implementation since modern CPUs can do the mults
+ * quickly enough */
+ diff = ((2 * delta + 1) * step) >> 3;
+ predictor = c->predictor;
+ if (sign) predictor -= diff;
+ else predictor += diff;
+
+ CLAMP_TO_SHORT(predictor);
+ c->predictor = predictor;
+ c->step_index = step_index;
+
+ return (short)predictor;
+}
+
+static inline short adpcm_4xa_expand_nibble(ADPCMChannelStatus *c, char nibble)
+{
+ int step_index;
+ int predictor;
+ int sign, delta, diff, step;
+
+ step = step_table[c->step_index];
+ step_index = c->step_index + index_table[(unsigned)nibble];
+ if (step_index < 0) step_index = 0;
+ else if (step_index > 88) step_index = 88;
+
+ sign = nibble & 8;
+ delta = nibble & 7;
+
+ diff = (delta*step + (step>>1))>>3; // difference to code above
+
+ predictor = c->predictor;
+ if (sign) predictor -= diff;
+ else predictor += diff;
+
+ CLAMP_TO_SHORT(predictor);
+ c->predictor = predictor;
+ c->step_index = step_index;
+
+ return (short)predictor;
+}
+
+static inline short adpcm_ms_expand_nibble(ADPCMChannelStatus *c, char nibble)
+{
+ int predictor;
+
+ predictor = (((c->sample1) * (c->coeff1)) + ((c->sample2) * (c->coeff2))) / 256;
+ predictor += (signed)((nibble & 0x08)?(nibble - 0x10):(nibble)) * c->idelta;
+ CLAMP_TO_SHORT(predictor);
+
+ c->sample2 = c->sample1;
+ c->sample1 = predictor;
+ c->idelta = (AdaptationTable[(int)nibble] * c->idelta) / 256;
+ if (c->idelta < 16) c->idelta = 16;
+
+ return (short)predictor;
+}
+
+static void xa_decode(short *out, const unsigned char *in,
+ ADPCMChannelStatus *left, ADPCMChannelStatus *right, int inc)
+{
+ int i, j;
+ int shift,filter,f0,f1;
+ int s_1,s_2;
+ int d,s,t;
+
+ for(i=0;i<4;i++) {
+
+ shift = 12 - (in[4+i*2] & 15);
+ filter = in[4+i*2] >> 4;
+ f0 = xa_adpcm_table[filter][0];
+ f1 = xa_adpcm_table[filter][1];
+
+ s_1 = left->sample1;
+ s_2 = left->sample2;
+
+ for(j=0;j<28;j++) {
+ d = in[16+i+j*4];
+
+ t = (signed char)(d<<4)>>4;
+ s = ( t<<shift ) + ((s_1*f0 + s_2*f1+32)>>6);
+ CLAMP_TO_SHORT(s);
+ *out = s;
+ out += inc;
+ s_2 = s_1;
+ s_1 = s;
+ }
+
+ if (inc==2) { /* stereo */
+ left->sample1 = s_1;
+ left->sample2 = s_2;
+ s_1 = right->sample1;
+ s_2 = right->sample2;
+ out = out + 1 - 28*2;
+ }
+
+ shift = 12 - (in[5+i*2] & 15);
+ filter = in[5+i*2] >> 4;
+
+ f0 = xa_adpcm_table[filter][0];
+ f1 = xa_adpcm_table[filter][1];
+
+ for(j=0;j<28;j++) {
+ d = in[16+i+j*4];
+
+ t = (signed char)d >> 4;
+ s = ( t<<shift ) + ((s_1*f0 + s_2*f1+32)>>6);
+ CLAMP_TO_SHORT(s);
+ *out = s;
+ out += inc;
+ s_2 = s_1;
+ s_1 = s;
+ }
+
+ if (inc==2) { /* stereo */
+ right->sample1 = s_1;
+ right->sample2 = s_2;
+ out -= 1;
+ } else {
+ left->sample1 = s_1;
+ left->sample2 = s_2;
+ }
+ }
+}
+
+
+/* DK3 ADPCM support macro */
+#define DK3_GET_NEXT_NIBBLE() \
+ if (decode_top_nibble_next) \
+ { \
+ nibble = (last_byte >> 4) & 0x0F; \
+ decode_top_nibble_next = 0; \
+ } \
+ else \
+ { \
+ last_byte = *src++; \
+ if (src >= buf + buf_size) break; \
+ nibble = last_byte & 0x0F; \
+ decode_top_nibble_next = 1; \
+ }
+
+static int adpcm_decode_frame(AVCodecContext *avctx,
+ void *data, int *data_size,
+ uint8_t *buf, int buf_size)
+{
+ ADPCMContext *c = avctx->priv_data;
+ ADPCMChannelStatus *cs;
+ int n, m, channel, i;
+ int block_predictor[2];
+ short *samples;
+ uint8_t *src;
+ int st; /* stereo */
+
+ /* DK3 ADPCM accounting variables */
+ unsigned char last_byte = 0;
+ unsigned char nibble;
+ int decode_top_nibble_next = 0;
+ int diff_channel;
+
+ samples = data;
+ src = buf;
+
+ st = avctx->channels == 2;
+
+ switch(avctx->codec->id) {
+ case CODEC_ID_ADPCM_IMA_QT:
+ n = (buf_size - 2);/* >> 2*avctx->channels;*/
+ channel = c->channel;
+ cs = &(c->status[channel]);
+ /* (pppppp) (piiiiiii) */
+
+ /* Bits 15-7 are the _top_ 9 bits of the 16-bit initial predictor value */
+ cs->predictor = (*src++) << 8;
+ cs->predictor |= (*src & 0x80);
+ cs->predictor &= 0xFF80;
+
+ /* sign extension */
+ if(cs->predictor & 0x8000)
+ cs->predictor -= 0x10000;
+
+ CLAMP_TO_SHORT(cs->predictor);
+
+ cs->step_index = (*src++) & 0x7F;
+
+ if (cs->step_index > 88) fprintf(stderr, "ERROR: step_index = %i\n", cs->step_index);
+ if (cs->step_index > 88) cs->step_index = 88;
+
+ cs->step = step_table[cs->step_index];
+
+ if (st && channel)
+ samples++;
+
+ *samples++ = cs->predictor;
+ samples += st;
+
+ for(m=32; n>0 && m>0; n--, m--) { /* in QuickTime, IMA is encoded by chuncks of 34 bytes (=64 samples) */
+ *samples = adpcm_ima_expand_nibble(cs, src[0] & 0x0F);
+ samples += avctx->channels;
+ *samples = adpcm_ima_expand_nibble(cs, (src[0] >> 4) & 0x0F);
+ samples += avctx->channels;
+ src ++;
+ }
+
+ if(st) { /* handle stereo interlacing */
+ c->channel = (channel + 1) % 2; /* we get one packet for left, then one for right data */
+ if(channel == 0) { /* wait for the other packet before outputing anything */
+ *data_size = 0;
+ return src - buf;
+ }
+ }
+ break;
+ case CODEC_ID_ADPCM_IMA_WAV:
+ if (buf_size > BLKSIZE) {
+ if (avctx->block_align != 0)
+ buf_size = avctx->block_align;
+ else
+ buf_size = BLKSIZE;
+ }
+ // XXX: do as per-channel loop
+ cs = &(c->status[0]);
+ cs->predictor = (*src++) & 0x0FF;
+ cs->predictor |= ((*src++) << 8) & 0x0FF00;
+ if(cs->predictor & 0x8000)
+ cs->predictor -= 0x10000;
+ CLAMP_TO_SHORT(cs->predictor);
+
+ // XXX: is this correct ??: *samples++ = cs->predictor;
+
+ cs->step_index = *src++;
+ if (cs->step_index < 0) cs->step_index = 0;
+ if (cs->step_index > 88) cs->step_index = 88;
+ if (*src++) fprintf(stderr, "unused byte should be null !!\n"); /* unused */
+
+ if (st) {
+ cs = &(c->status[1]);
+ cs->predictor = (*src++) & 0x0FF;
+ cs->predictor |= ((*src++) << 8) & 0x0FF00;
+ if(cs->predictor & 0x8000)
+ cs->predictor -= 0x10000;
+ CLAMP_TO_SHORT(cs->predictor);
+
+ // XXX: is this correct ??: *samples++ = cs->predictor;
+
+ cs->step_index = *src++;
+ if (cs->step_index < 0) cs->step_index = 0;
+ if (cs->step_index > 88) cs->step_index = 88;
+ src++; /* if != 0 -> out-of-sync */
+ }
+
+ for(m=4; src < (buf + buf_size);) {
+ *samples++ = adpcm_ima_expand_nibble(&c->status[0], src[0] & 0x0F);
+ if (st)
+ *samples++ = adpcm_ima_expand_nibble(&c->status[1], src[4] & 0x0F);
+ *samples++ = adpcm_ima_expand_nibble(&c->status[0], (src[0] >> 4) & 0x0F);
+ if (st) {
+ *samples++ = adpcm_ima_expand_nibble(&c->status[1], (src[4] >> 4) & 0x0F);
+ if (!--m) {
+ m=4;
+ src+=4;
+ }
+ }
+ src++;
+ }
+ break;
+ case CODEC_ID_ADPCM_4XM:
+ cs = &(c->status[0]);
+ c->status[0].predictor= (int16_t)(src[0] + (src[1]<<8)); src+=2;
+ if(st){
+ c->status[1].predictor= (int16_t)(src[0] + (src[1]<<8)); src+=2;
+ }
+ c->status[0].step_index= (int16_t)(src[0] + (src[1]<<8)); src+=2;
+ if(st){
+ c->status[1].step_index= (int16_t)(src[0] + (src[1]<<8)); src+=2;
+ }
+// if (cs->step_index < 0) cs->step_index = 0;
+// if (cs->step_index > 88) cs->step_index = 88;
+
+ m= (buf_size - (src - buf))>>st;
+//printf("%d %d %d %d\n", st, m, c->status[0].predictor, c->status[0].step_index);
+ //FIXME / XXX decode chanels individual & interleave samples
+ for(i=0; i<m; i++) {
+ *samples++ = adpcm_4xa_expand_nibble(&c->status[0], src[i] & 0x0F);
+ if (st)
+ *samples++ = adpcm_4xa_expand_nibble(&c->status[1], src[i+m] & 0x0F);
+ *samples++ = adpcm_4xa_expand_nibble(&c->status[0], src[i] >> 4);
+ if (st)
+ *samples++ = adpcm_4xa_expand_nibble(&c->status[1], src[i+m] >> 4);
+ }
+
+ src += m<<st;
+
+ break;
+ case CODEC_ID_ADPCM_MS:
+
+ if (buf_size > BLKSIZE) {
+ if (avctx->block_align != 0)
+ buf_size = avctx->block_align;
+ else
+ buf_size = BLKSIZE;
+ }
+ n = buf_size - 7 * avctx->channels;
+ if (n < 0)
+ return -1;
+ block_predictor[0] = (*src++); /* should be bound */
+ block_predictor[0] = (block_predictor[0] < 0)?(0):((block_predictor[0] > 7)?(7):(block_predictor[0]));
+ block_predictor[1] = 0;
+ if (st)
+ block_predictor[1] = (*src++);
+ block_predictor[1] = (block_predictor[1] < 0)?(0):((block_predictor[1] > 7)?(7):(block_predictor[1]));
+ c->status[0].idelta = ((*src & 0xFF) | ((src[1] << 8) & 0xFF00));
+ if (c->status[0].idelta & 0x08000)
+ c->status[0].idelta -= 0x10000;
+ src+=2;
+ if (st)
+ c->status[1].idelta = ((*src & 0xFF) | ((src[1] << 8) & 0xFF00));
+ if (st && c->status[1].idelta & 0x08000)
+ c->status[1].idelta |= 0xFFFF0000;
+ if (st)
+ src+=2;
+ c->status[0].coeff1 = AdaptCoeff1[block_predictor[0]];
+ c->status[0].coeff2 = AdaptCoeff2[block_predictor[0]];
+ c->status[1].coeff1 = AdaptCoeff1[block_predictor[1]];
+ c->status[1].coeff2 = AdaptCoeff2[block_predictor[1]];
+
+ c->status[0].sample1 = ((*src & 0xFF) | ((src[1] << 8) & 0xFF00));
+ src+=2;
+ if (st) c->status[1].sample1 = ((*src & 0xFF) | ((src[1] << 8) & 0xFF00));
+ if (st) src+=2;
+ c->status[0].sample2 = ((*src & 0xFF) | ((src[1] << 8) & 0xFF00));
+ src+=2;
+ if (st) c->status[1].sample2 = ((*src & 0xFF) | ((src[1] << 8) & 0xFF00));
+ if (st) src+=2;
+
+ *samples++ = c->status[0].sample1;
+ if (st) *samples++ = c->status[1].sample1;
+ *samples++ = c->status[0].sample2;
+ if (st) *samples++ = c->status[1].sample2;
+ for(;n>0;n--) {
+ *samples++ = adpcm_ms_expand_nibble(&c->status[0], (src[0] >> 4) & 0x0F);
+ *samples++ = adpcm_ms_expand_nibble(&c->status[st], src[0] & 0x0F);
+ src ++;
+ }
+ break;
+ case CODEC_ID_ADPCM_IMA_DK4:
+ if (buf_size > BLKSIZE) {
+ if (avctx->block_align != 0)
+ buf_size = avctx->block_align;
+ else
+ buf_size = BLKSIZE;
+ }
+ c->status[0].predictor = (src[0] | (src[1] << 8));
+ c->status[0].step_index = src[2];
+ src += 4;
+ if(c->status[0].predictor & 0x8000)
+ c->status[0].predictor -= 0x10000;
+ *samples++ = c->status[0].predictor;
+ if (st) {
+ c->status[1].predictor = (src[0] | (src[1] << 8));
+ c->status[1].step_index = src[2];
+ src += 4;
+ if(c->status[1].predictor & 0x8000)
+ c->status[1].predictor -= 0x10000;
+ *samples++ = c->status[1].predictor;
+ }
+ while (src < buf + buf_size) {
+
+ /* take care of the top nibble (always left or mono channel) */
+ *samples++ = adpcm_ima_expand_nibble(&c->status[0],
+ (src[0] >> 4) & 0x0F);
+
+ /* take care of the bottom nibble, which is right sample for
+ * stereo, or another mono sample */
+ if (st)
+ *samples++ = adpcm_ima_expand_nibble(&c->status[1],
+ src[0] & 0x0F);
+ else
+ *samples++ = adpcm_ima_expand_nibble(&c->status[0],
+ src[0] & 0x0F);
+
+ src++;
+ }
+ break;
+ case CODEC_ID_ADPCM_IMA_DK3:
+ if (buf_size > BLKSIZE) {
+ if (avctx->block_align != 0)
+ buf_size = avctx->block_align;
+ else
+ buf_size = BLKSIZE;
+ }
+ c->status[0].predictor = (src[10] | (src[11] << 8));
+ c->status[1].predictor = (src[12] | (src[13] << 8));
+ c->status[0].step_index = src[14];
+ c->status[1].step_index = src[15];
+ /* sign extend the predictors */
+ if(c->status[0].predictor & 0x8000)
+ c->status[0].predictor -= 0x10000;
+ if(c->status[1].predictor & 0x8000)
+ c->status[1].predictor -= 0x10000;
+ src += 16;
+ diff_channel = c->status[1].predictor;
+
+ /* the DK3_GET_NEXT_NIBBLE macro issues the break statement when
+ * the buffer is consumed */
+ while (1) {
+
+ /* for this algorithm, c->status[0] is the sum channel and
+ * c->status[1] is the diff channel */
+
+ /* process the first predictor of the sum channel */
+ DK3_GET_NEXT_NIBBLE();
+ adpcm_ima_expand_nibble(&c->status[0], nibble);
+
+ /* process the diff channel predictor */
+ DK3_GET_NEXT_NIBBLE();
+ adpcm_ima_expand_nibble(&c->status[1], nibble);
+
+ /* process the first pair of stereo PCM samples */
+ diff_channel = (diff_channel + c->status[1].predictor) / 2;
+ *samples++ = c->status[0].predictor + c->status[1].predictor;
+ *samples++ = c->status[0].predictor - c->status[1].predictor;
+
+ /* process the second predictor of the sum channel */
+ DK3_GET_NEXT_NIBBLE();
+ adpcm_ima_expand_nibble(&c->status[0], nibble);
+
+ /* process the second pair of stereo PCM samples */
+ diff_channel = (diff_channel + c->status[1].predictor) / 2;
+ *samples++ = c->status[0].predictor + c->status[1].predictor;
+ *samples++ = c->status[0].predictor - c->status[1].predictor;
+ }
+ break;
+ case CODEC_ID_ADPCM_IMA_WS:
+ /* no per-block initialization; just start decoding the data */
+ while (src < buf + buf_size) {
+
+ if (st) {
+ *samples++ = adpcm_ima_expand_nibble(&c->status[0],
+ (src[0] >> 4) & 0x0F);
+ *samples++ = adpcm_ima_expand_nibble(&c->status[1],
+ src[0] & 0x0F);
+ } else {
+ *samples++ = adpcm_ima_expand_nibble(&c->status[0],
+ (src[0] >> 4) & 0x0F);
+ *samples++ = adpcm_ima_expand_nibble(&c->status[0],
+ src[0] & 0x0F);
+ }
+
+ src++;
+ }
+ break;
+ case CODEC_ID_ADPCM_XA:
+ c->status[0].sample1 = c->status[0].sample2 =
+ c->status[1].sample1 = c->status[1].sample2 = 0;
+ while (buf_size >= 128) {
+ xa_decode(samples, src, &c->status[0], &c->status[1],
+ avctx->channels);
+ src += 128;
+ samples += 28 * 8;
+ buf_size -= 128;
+ }
+ break;
+ default:
+ *data_size = 0;
+ return -1;
+ }
+ *data_size = (uint8_t *)samples - (uint8_t *)data;
+ return src - buf;
+}
+
+
+
+#ifdef CONFIG_ENCODERS
+#define ADPCM_ENCODER(id,name) \
+AVCodec name ## _encoder = { \
+ #name, \
+ CODEC_TYPE_AUDIO, \
+ id, \
+ sizeof(ADPCMContext), \
+ adpcm_encode_init, \
+ adpcm_encode_frame, \
+ adpcm_encode_close, \
+ NULL, \
+};
+#else
+#define ADPCM_ENCODER(id,name)
+#endif
+
+#ifdef CONFIG_DECODERS
+#define ADPCM_DECODER(id,name) \
+AVCodec name ## _decoder = { \
+ #name, \
+ CODEC_TYPE_AUDIO, \
+ id, \
+ sizeof(ADPCMContext), \
+ adpcm_decode_init, \
+ NULL, \
+ NULL, \
+ adpcm_decode_frame, \
+};
+#else
+#define ADPCM_DECODER(id,name)
+#endif
+
+#define ADPCM_CODEC(id, name) \
+ADPCM_ENCODER(id,name) ADPCM_DECODER(id,name)
+
+ADPCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
+ADPCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
+ADPCM_CODEC(CODEC_ID_ADPCM_IMA_DK3, adpcm_ima_dk3);
+ADPCM_CODEC(CODEC_ID_ADPCM_IMA_DK4, adpcm_ima_dk4);
+ADPCM_CODEC(CODEC_ID_ADPCM_IMA_WS, adpcm_ima_ws);
+ADPCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
+ADPCM_CODEC(CODEC_ID_ADPCM_4XM, adpcm_4xm);
+ADPCM_CODEC(CODEC_ID_ADPCM_XA, adpcm_xa);
+ADPCM_CODEC(CODEC_ID_ADPCM_ADX, adpcm_adx);
+
+#undef ADPCM_CODEC
diff --git a/src/libffmpeg/libavcodec/adx.c b/src/libffmpeg/libavcodec/adx.c
new file mode 100644
index 000000000..4fdca49e8
--- /dev/null
+++ b/src/libffmpeg/libavcodec/adx.c
@@ -0,0 +1,407 @@
+/*
+ * ADX ADPCM codecs
+ * Copyright (c) 2001,2003 BERO
+ *
+ * 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"
+
+/**
+ * @file adx.c
+ * SEGA CRI adx codecs.
+ *
+ * Reference documents:
+ * http://ku-www.ss.titech.ac.jp/~yatsushi/adx.html
+ * adx2wav & wav2adx http://www.geocities.co.jp/Playtown/2004/
+ */
+
+typedef struct {
+ int s1,s2;
+} PREV;
+
+typedef struct {
+ PREV prev[2];
+ int header_parsed;
+ unsigned char dec_temp[18*2];
+ unsigned short enc_temp[32*2];
+ int in_temp;
+} ADXContext;
+
+//#define BASEVOL 0x11e0
+#define BASEVOL 0x4000
+#define SCALE1 0x7298
+#define SCALE2 0x3350
+
+#define CLIP(s) if (s>32767) s=32767; else if (s<-32768) s=-32768
+
+/* 18 bytes <-> 32 samples */
+
+#ifdef CONFIG_ENCODERS
+static void adx_encode(unsigned char *adx,const short *wav,PREV *prev)
+{
+ int scale;
+ int i;
+ int s0,s1,s2,d;
+ int max=0;
+ int min=0;
+ int data[32];
+
+ s1 = prev->s1;
+ s2 = prev->s2;
+ for(i=0;i<32;i++) {
+ s0 = wav[i];
+ d = ((s0<<14) - SCALE1*s1 + SCALE2*s2)/BASEVOL;
+ data[i]=d;
+ if (max<d) max=d;
+ if (min>d) min=d;
+ s2 = s1;
+ s1 = s0;
+ }
+ prev->s1 = s1;
+ prev->s2 = s2;
+
+ /* -8..+7 */
+
+ if (max==0 && min==0) {
+ memset(adx,0,18);
+ return;
+ }
+
+ if (max/7>-min/8) scale = max/7;
+ else scale = -min/8;
+
+ if (scale==0) scale=1;
+
+ adx[0] = scale>>8;
+ adx[1] = scale;
+
+ for(i=0;i<16;i++) {
+ adx[i+2] = ((data[i*2]/scale)<<4) | ((data[i*2+1]/scale)&0xf);
+ }
+}
+#endif //CONFIG_ENCODERS
+
+static void adx_decode(short *out,const unsigned char *in,PREV *prev)
+{
+ int scale = ((in[0]<<8)|(in[1]));
+ int i;
+ int s0,s1,s2,d;
+
+// printf("%x ",scale);
+
+ in+=2;
+ s1 = prev->s1;
+ s2 = prev->s2;
+ for(i=0;i<16;i++) {
+ d = in[i];
+ // d>>=4; if (d&8) d-=16;
+ d = ((signed char)d >> 4);
+ s0 = (BASEVOL*d*scale + SCALE1*s1 - SCALE2*s2)>>14;
+ CLIP(s0);
+ *out++=s0;
+ s2 = s1;
+ s1 = s0;
+
+ d = in[i];
+ //d&=15; if (d&8) d-=16;
+ d = ((signed char)(d<<4) >> 4);
+ s0 = (BASEVOL*d*scale + SCALE1*s1 - SCALE2*s2)>>14;
+ CLIP(s0);
+ *out++=s0;
+ s2 = s1;
+ s1 = s0;
+ }
+ prev->s1 = s1;
+ prev->s2 = s2;
+
+}
+
+static void adx_decode_stereo(short *out,const unsigned char *in,PREV *prev)
+{
+ short tmp[32*2];
+ int i;
+
+ adx_decode(tmp ,in ,prev);
+ adx_decode(tmp+32,in+18,prev+1);
+ for(i=0;i<32;i++) {
+ out[i*2] = tmp[i];
+ out[i*2+1] = tmp[i+32];
+ }
+}
+
+#ifdef CONFIG_ENCODERS
+
+static void write_long(unsigned char *p,uint32_t v)
+{
+ p[0] = v>>24;
+ p[1] = v>>16;
+ p[2] = v>>8;
+ p[3] = v;
+}
+
+static int adx_encode_header(AVCodecContext *avctx,unsigned char *buf,size_t bufsize)
+{
+#if 0
+ struct {
+ uint32_t offset; /* 0x80000000 + sample start - 4 */
+ unsigned char unknown1[3]; /* 03 12 04 */
+ unsigned char channel; /* 1 or 2 */
+ uint32_t freq;
+ uint32_t size;
+ uint32_t unknown2; /* 01 f4 03 00 */
+ uint32_t unknown3; /* 00 00 00 00 */
+ uint32_t unknown4; /* 00 00 00 00 */
+
+ /* if loop
+ unknown3 00 15 00 01
+ unknown4 00 00 00 01
+ long loop_start_sample;
+ long loop_start_byte;
+ long loop_end_sample;
+ long loop_end_byte;
+ long
+ */
+ } adxhdr; /* big endian */
+ /* offset-6 "(c)CRI" */
+#endif
+ write_long(buf+0x00,0x80000000|0x20);
+ write_long(buf+0x04,0x03120400|avctx->channels);
+ write_long(buf+0x08,avctx->sample_rate);
+ write_long(buf+0x0c,0); /* FIXME: set after */
+ write_long(buf+0x10,0x01040300);
+ write_long(buf+0x14,0x00000000);
+ write_long(buf+0x18,0x00000000);
+ memcpy(buf+0x1c,"\0\0(c)CRI",8);
+ return 0x20+4;
+}
+
+static int adx_decode_init(AVCodecContext *avctx);
+static int adx_encode_init(AVCodecContext *avctx)
+{
+ if (avctx->channels > 2)
+ return -1; /* only stereo or mono =) */
+ avctx->frame_size = 32;
+
+ avctx->coded_frame= avcodec_alloc_frame();
+ avctx->coded_frame->key_frame= 1;
+
+// avctx->bit_rate = avctx->sample_rate*avctx->channels*18*8/32;
+
+ printf("adx encode init\n"); fflush(stdout);
+ adx_decode_init(avctx);
+
+ return 0;
+}
+
+static int adx_encode_close(AVCodecContext *avctx)
+{
+ av_freep(&avctx->coded_frame);
+
+ return 0;
+}
+
+static int adx_encode_frame(AVCodecContext *avctx,
+ unsigned char *frame, int buf_size, const void *data)
+{
+ ADXContext *c = avctx->priv_data;
+ const short *samples = data;
+ unsigned char *dst = frame;
+ int rest = avctx->frame_size;
+
+/*
+ input data size =
+ ffmpeg.c: do_audio_out()
+ frame_bytes = enc->frame_size * 2 * enc->channels;
+*/
+
+// printf("sz=%d ",buf_size); fflush(stdout);
+ if (!c->header_parsed) {
+ int hdrsize = adx_encode_header(avctx,dst,buf_size);
+ dst+=hdrsize;
+ c->header_parsed = 1;
+ }
+
+ if (avctx->channels==1) {
+ while(rest>=32) {
+ adx_encode(dst,samples,c->prev);
+ dst+=18;
+ samples+=32;
+ rest-=32;
+ }
+ } else {
+ while(rest>=32*2) {
+ short tmpbuf[32*2];
+ int i;
+
+ for(i=0;i<32;i++) {
+ tmpbuf[i] = samples[i*2];
+ tmpbuf[i+32] = samples[i*2+1];
+ }
+
+ adx_encode(dst,tmpbuf,c->prev);
+ adx_encode(dst+18,tmpbuf+32,c->prev+1);
+ dst+=18*2;
+ samples+=32*2;
+ rest-=32*2;
+ }
+ }
+ return dst-frame;
+}
+
+#endif //CONFIG_ENCODERS
+
+static uint32_t read_long(const unsigned char *p)
+{
+ return (p[0]<<24)|(p[1]<<16)|(p[2]<<8)|p[3];
+}
+
+int is_adx(const unsigned char *buf,size_t bufsize)
+{
+ int offset;
+
+ if (buf[0]!=0x80) return 0;
+ offset = (read_long(buf)^0x80000000)+4;
+ if (bufsize<offset || memcmp(buf+offset-6,"(c)CRI",6)) return 0;
+ return offset;
+}
+
+/* return data offset or 6 */
+static int adx_decode_header(AVCodecContext *avctx,const unsigned char *buf,size_t bufsize)
+{
+ int offset;
+ int channels,freq,size;
+
+ offset = is_adx(buf,bufsize);
+ if (offset==0) return 0;
+
+ channels = buf[7];
+ freq = read_long(buf+8);
+ size = read_long(buf+12);
+
+// printf("freq=%d ch=%d\n",freq,channels);
+
+ avctx->sample_rate = freq;
+ avctx->channels = channels;
+ avctx->bit_rate = freq*channels*18*8/32;
+// avctx->frame_size = 18*channels;
+
+ return offset;
+}
+
+static int adx_decode_init(AVCodecContext * avctx)
+{
+ ADXContext *c = avctx->priv_data;
+
+// printf("adx_decode_init\n"); fflush(stdout);
+ c->prev[0].s1 = 0;
+ c->prev[0].s2 = 0;
+ c->prev[1].s1 = 0;
+ c->prev[1].s2 = 0;
+ c->header_parsed = 0;
+ c->in_temp = 0;
+ return 0;
+}
+
+static void dump(unsigned char *buf,size_t len)
+{
+ int i;
+ for(i=0;i<len;i++) {
+ if ((i&15)==0) printf("%04x ",i);
+ printf("%02x ",buf[i]);
+ if ((i&15)==15) printf("\n");
+ }
+ printf("\n");
+}
+static int adx_decode_frame(AVCodecContext *avctx,
+ void *data, int *data_size,
+ const uint8_t *buf0, int buf_size)
+{
+ ADXContext *c = avctx->priv_data;
+ short *samples = data;
+ const uint8_t *buf = buf0;
+ int rest = buf_size;
+
+ if (!c->header_parsed) {
+ int hdrsize = adx_decode_header(avctx,buf,rest);
+ if (hdrsize==0) return -1;
+ c->header_parsed = 1;
+ buf += hdrsize;
+ rest -= hdrsize;
+ }
+
+ if (c->in_temp) {
+ int copysize = 18*avctx->channels - c->in_temp;
+ memcpy(c->dec_temp+c->in_temp,buf,copysize);
+ rest -= copysize;
+ buf += copysize;
+ if (avctx->channels==1) {
+ adx_decode(samples,c->dec_temp,c->prev);
+ samples += 32;
+ } else {
+ adx_decode_stereo(samples,c->dec_temp,c->prev);
+ samples += 32*2;
+ }
+ }
+ //
+ if (avctx->channels==1) {
+ while(rest>=18) {
+ adx_decode(samples,buf,c->prev);
+ rest-=18;
+ buf+=18;
+ samples+=32;
+ }
+ } else {
+ while(rest>=18*2) {
+ adx_decode_stereo(samples,buf,c->prev);
+ rest-=18*2;
+ buf+=18*2;
+ samples+=32*2;
+ }
+ }
+ //
+ c->in_temp = rest;
+ if (rest) {
+ memcpy(c->dec_temp,buf,rest);
+ buf+=rest;
+ }
+ *data_size = (uint8_t*)samples - (uint8_t*)data;
+// printf("%d:%d ",buf-buf0,*data_size); fflush(stdout);
+ return buf-buf0;
+}
+
+#ifdef CONFIG_ENCODERS
+AVCodec adx_adpcm_encoder = {
+ "adx_adpcm",
+ CODEC_TYPE_AUDIO,
+ CODEC_ID_ADPCM_ADX,
+ sizeof(ADXContext),
+ adx_encode_init,
+ adx_encode_frame,
+ adx_encode_close,
+ NULL,
+};
+#endif //CONFIG_ENCODERS
+
+AVCodec adx_adpcm_decoder = {
+ "adx_adpcm",
+ CODEC_TYPE_AUDIO,
+ CODEC_ID_ADPCM_ADX,
+ sizeof(ADXContext),
+ adx_decode_init,
+ NULL,
+ NULL,
+ adx_decode_frame,
+};
+
diff --git a/src/libffmpeg/libavcodec/alpha/asm.h b/src/libffmpeg/libavcodec/alpha/asm.h
index c2983125a..21a737d3f 100644
--- a/src/libffmpeg/libavcodec/alpha/asm.h
+++ b/src/libffmpeg/libavcodec/alpha/asm.h
@@ -42,14 +42,14 @@
#define AMASK_CIX (1 << 2)
#define AMASK_MVI (1 << 8)
-inline static uint64_t BYTE_VEC(uint64_t x)
+static inline uint64_t BYTE_VEC(uint64_t x)
{
x |= x << 8;
x |= x << 16;
x |= x << 32;
return x;
}
-inline static uint64_t WORD_VEC(uint64_t x)
+static inline uint64_t WORD_VEC(uint64_t x)
{
x |= x << 16;
x |= x << 32;
@@ -63,27 +63,15 @@ inline static uint64_t WORD_VEC(uint64_t x)
#define sextw(x) ((int16_t) (x))
#ifdef __GNUC__
-#define ASM_ACCEPT_MVI asm (".arch pca56")
struct unaligned_long { uint64_t l; } __attribute__((packed));
#define ldq_u(p) (*(const uint64_t *) (((uint64_t) (p)) & ~7ul))
#define uldq(a) (((const struct unaligned_long *) (a))->l)
-#if GNUC_PREREQ(3,0)
-/* Unfortunately, __builtin_prefetch is slightly buggy on Alpha. The
- defines here are kludged so we still get the right
- instruction. This needs to be adapted as soon as gcc is fixed. */
-# define prefetch(p) __builtin_prefetch((p), 0, 1)
-# define prefetch_en(p) __builtin_prefetch((p), 1, 1)
-# define prefetch_m(p) __builtin_prefetch((p), 0, 0)
-# define prefetch_men(p) __builtin_prefetch((p), 1, 0)
-#else
-# define prefetch(p) asm volatile("ldl $31,%0" : : "m"(*(const char *) (p)) : "memory")
-# define prefetch_en(p) asm volatile("ldq $31,%0" : : "m"(*(const char *) (p)) : "memory")
-# define prefetch_m(p) asm volatile("lds $f31,%0" : : "m"(*(const char *) (p)) : "memory")
-# define prefetch_men(p) asm volatile("ldt $f31,%0" : : "m"(*(const char *) (p)) : "memory")
-#endif
-
#if GNUC_PREREQ(3,3)
+#define prefetch(p) __builtin_prefetch((p), 0, 1)
+#define prefetch_en(p) __builtin_prefetch((p), 0, 0)
+#define prefetch_m(p) __builtin_prefetch((p), 1, 1)
+#define prefetch_men(p) __builtin_prefetch((p), 1, 0)
#define cmpbge __builtin_alpha_cmpbge
/* Avoid warnings. */
#define extql(a, b) __builtin_alpha_extql(a, (uint64_t) (b))
@@ -94,6 +82,24 @@ struct unaligned_long { uint64_t l; } __attribute__((packed));
#define amask __builtin_alpha_amask
#define implver __builtin_alpha_implver
#define rpcc __builtin_alpha_rpcc
+#else
+#define prefetch(p) asm volatile("ldl $31,%0" : : "m"(*(const char *) (p)) : "memory")
+#define prefetch_en(p) asm volatile("ldq $31,%0" : : "m"(*(const char *) (p)) : "memory")
+#define prefetch_m(p) asm volatile("lds $f31,%0" : : "m"(*(const char *) (p)) : "memory")
+#define prefetch_men(p) asm volatile("ldt $f31,%0" : : "m"(*(const char *) (p)) : "memory")
+#define cmpbge(a, b) ({ uint64_t __r; asm ("cmpbge %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; })
+#define extql(a, b) ({ uint64_t __r; asm ("extql %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; })
+#define extwl(a, b) ({ uint64_t __r; asm ("extwl %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; })
+#define extqh(a, b) ({ uint64_t __r; asm ("extqh %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; })
+#define zap(a, b) ({ uint64_t __r; asm ("zap %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; })
+#define zapnot(a, b) ({ uint64_t __r; asm ("zapnot %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; })
+#define amask(a) ({ uint64_t __r; asm ("amask %1,%0" : "=r" (__r) : "rI" (a)); __r; })
+#define implver() ({ uint64_t __r; asm ("implver %0" : "=r" (__r)); __r; })
+#define rpcc() ({ uint64_t __r; asm volatile ("rpcc %0" : "=r" (__r)); __r; })
+#endif
+#define wh64(p) asm volatile("wh64 (%0)" : : "r"(p) : "memory")
+
+#if GNUC_PREREQ(3,3) && defined(__alpha_max__)
#define minub8 __builtin_alpha_minub8
#define minsb8 __builtin_alpha_minsb8
#define minuw4 __builtin_alpha_minuw4
@@ -108,34 +114,24 @@ struct unaligned_long { uint64_t l; } __attribute__((packed));
#define unpkbl __builtin_alpha_unpkbl
#define unpkbw __builtin_alpha_unpkbw
#else
-#define cmpbge(a, b) ({ uint64_t __r; asm ("cmpbge %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; })
-#define extql(a, b) ({ uint64_t __r; asm ("extql %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; })
-#define extwl(a, b) ({ uint64_t __r; asm ("extwl %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; })
-#define extqh(a, b) ({ uint64_t __r; asm ("extqh %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; })
-#define zap(a, b) ({ uint64_t __r; asm ("zap %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; })
-#define zapnot(a, b) ({ uint64_t __r; asm ("zapnot %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; })
-#define amask(a) ({ uint64_t __r; asm ("amask %1,%0" : "=r" (__r) : "rI" (a)); __r; })
-#define implver() ({ uint64_t __r; asm ("implver %0" : "=r" (__r)); __r; })
-#define rpcc() ({ uint64_t __r; asm volatile ("rpcc %0" : "=r" (__r)); __r; })
-#define minub8(a, b) ({ uint64_t __r; asm ("minub8 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
-#define minsb8(a, b) ({ uint64_t __r; asm ("minsb8 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
-#define minuw4(a, b) ({ uint64_t __r; asm ("minuw4 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
-#define minsw4(a, b) ({ uint64_t __r; asm ("minsw4 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
-#define maxub8(a, b) ({ uint64_t __r; asm ("maxub8 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
-#define maxsb8(a, b) ({ uint64_t __r; asm ("maxsb8 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
-#define maxuw4(a, b) ({ uint64_t __r; asm ("maxuw4 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
-#define maxsw4(a, b) ({ uint64_t __r; asm ("maxsw4 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
-#define perr(a, b) ({ uint64_t __r; asm ("perr %r1,%r2,%0" : "=r" (__r) : "%rJ" (a), "rJ" (b)); __r; })
-#define pklb(a) ({ uint64_t __r; asm ("pklb %r1,%0" : "=r" (__r) : "rJ" (a)); __r; })
-#define pkwb(a) ({ uint64_t __r; asm ("pkwb %r1,%0" : "=r" (__r) : "rJ" (a)); __r; })
-#define unpkbl(a) ({ uint64_t __r; asm ("unpkbl %r1,%0" : "=r" (__r) : "rJ" (a)); __r; })
-#define unpkbw(a) ({ uint64_t __r; asm ("unpkbw %r1,%0" : "=r" (__r) : "rJ" (a)); __r; })
+#define minub8(a, b) ({ uint64_t __r; asm (".arch ev6; minub8 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
+#define minsb8(a, b) ({ uint64_t __r; asm (".arch ev6; minsb8 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
+#define minuw4(a, b) ({ uint64_t __r; asm (".arch ev6; minuw4 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
+#define minsw4(a, b) ({ uint64_t __r; asm (".arch ev6; minsw4 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
+#define maxub8(a, b) ({ uint64_t __r; asm (".arch ev6; maxub8 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
+#define maxsb8(a, b) ({ uint64_t __r; asm (".arch ev6; maxsb8 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
+#define maxuw4(a, b) ({ uint64_t __r; asm (".arch ev6; maxuw4 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
+#define maxsw4(a, b) ({ uint64_t __r; asm (".arch ev6; maxsw4 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
+#define perr(a, b) ({ uint64_t __r; asm (".arch ev6; perr %r1,%r2,%0" : "=r" (__r) : "%rJ" (a), "rJ" (b)); __r; })
+#define pklb(a) ({ uint64_t __r; asm (".arch ev6; pklb %r1,%0" : "=r" (__r) : "rJ" (a)); __r; })
+#define pkwb(a) ({ uint64_t __r; asm (".arch ev6; pkwb %r1,%0" : "=r" (__r) : "rJ" (a)); __r; })
+#define unpkbl(a) ({ uint64_t __r; asm (".arch ev6; unpkbl %r1,%0" : "=r" (__r) : "rJ" (a)); __r; })
+#define unpkbw(a) ({ uint64_t __r; asm (".arch ev6; unpkbw %r1,%0" : "=r" (__r) : "rJ" (a)); __r; })
#endif
#elif defined(__DECC) /* Digital/Compaq/hp "ccc" compiler */
#include <c_asm.h>
-#define ASM_ACCEPT_MVI
#define ldq_u(a) asm ("ldq_u %v0,0(%a0)", a)
#define uldq(a) (*(const __unaligned uint64_t *) (a))
#define cmpbge(a, b) asm ("cmpbge %a0,%a1,%v0", a, b)
@@ -160,6 +156,7 @@ struct unaligned_long { uint64_t l; } __attribute__((packed));
#define pkwb(a) asm ("pkwb %a0,%v0", a)
#define unpkbl(a) asm ("unpkbl %a0,%v0", a)
#define unpkbw(a) asm ("unpkbw %a0,%v0", a)
+#define wh64(a) asm ("wh64 %a0", a)
#else
#error "Unknown compiler!"
diff --git a/src/libffmpeg/libavcodec/alpha/dsputil_alpha.c b/src/libffmpeg/libavcodec/alpha/dsputil_alpha.c
index cdc8a6d5a..82ff7db66 100644
--- a/src/libffmpeg/libavcodec/alpha/dsputil_alpha.c
+++ b/src/libffmpeg/libavcodec/alpha/dsputil_alpha.c
@@ -20,6 +20,7 @@
#include "asm.h"
#include "../dsputil.h"
+extern void simple_idct_axp(DCTELEM *block);
extern void simple_idct_put_axp(uint8_t *dest, int line_size, DCTELEM *block);
extern void simple_idct_add_axp(uint8_t *dest, int line_size, DCTELEM *block);
@@ -53,8 +54,6 @@ static void put_pixels_clamped_mvi(const DCTELEM *block, uint8_t *pixels,
int i = 8;
uint64_t clampmask = zap(-1, 0xaa); /* 0x00ff00ff00ff00ff */
- ASM_ACCEPT_MVI;
-
do {
uint64_t shorts0, shorts1;
@@ -83,8 +82,6 @@ void add_pixels_clamped_mvi(const DCTELEM *block, uint8_t *pixels,
uint64_t signmask = zap(-1, 0x33);
signmask ^= signmask >> 1; /* 0x8000800080008000 */
- ASM_ACCEPT_MVI;
-
do {
uint64_t shorts0, pix0, signs0;
uint64_t shorts1, pix1, signs1;
@@ -363,4 +360,5 @@ void dsputil_init_alpha(DSPContext* c, AVCodecContext *avctx)
c->idct_put = simple_idct_put_axp;
c->idct_add = simple_idct_add_axp;
+ c->idct = simple_idct_axp;
}
diff --git a/src/libffmpeg/libavcodec/alpha/mpegvideo_alpha.c b/src/libffmpeg/libavcodec/alpha/mpegvideo_alpha.c
index 1a58e5dfd..6b720373c 100644
--- a/src/libffmpeg/libavcodec/alpha/mpegvideo_alpha.c
+++ b/src/libffmpeg/libavcodec/alpha/mpegvideo_alpha.c
@@ -59,7 +59,6 @@ static void dct_unquantize_h263_axp(MpegEncContext *s, DCTELEM *block,
#ifdef __alpha_max__
/* I don't think the speed difference justifies runtime
detection. */
- ASM_ACCEPT_MVI;
negmask = maxsw4(levels, -1); /* negative -> ffff (-1) */
negmask = minsw4(negmask, 0); /* positive -> 0000 (0) */
#else
diff --git a/src/libffmpeg/libavcodec/armv4l/dsputil_arm.c b/src/libffmpeg/libavcodec/armv4l/dsputil_arm.c
index e3cc05f63..ff61097d7 100644
--- a/src/libffmpeg/libavcodec/armv4l/dsputil_arm.c
+++ b/src/libffmpeg/libavcodec/armv4l/dsputil_arm.c
@@ -20,6 +20,7 @@
#include "../dsputil.h"
extern void j_rev_dct_ARM(DCTELEM *data);
+extern void simple_idct_ARM(DCTELEM *data);
/* XXX: local hack */
static void (*ff_put_pixels_clamped)(const DCTELEM *block, uint8_t *pixels, int line_size);
@@ -27,16 +28,26 @@ static void (*ff_add_pixels_clamped)(const DCTELEM *block, uint8_t *pixels, int
/* XXX: those functions should be suppressed ASAP when all IDCTs are
converted */
-static void arm_idct_put(uint8_t *dest, int line_size, DCTELEM *block)
+static void j_rev_dct_ARM_put(uint8_t *dest, int line_size, DCTELEM *block)
{
j_rev_dct_ARM (block);
ff_put_pixels_clamped(block, dest, line_size);
}
-static void arm_idct_add(uint8_t *dest, int line_size, DCTELEM *block)
+static void j_rev_dct_ARM_add(uint8_t *dest, int line_size, DCTELEM *block)
{
j_rev_dct_ARM (block);
ff_add_pixels_clamped(block, dest, line_size);
}
+static void simple_idct_ARM_put(uint8_t *dest, int line_size, DCTELEM *block)
+{
+ simple_idct_ARM (block);
+ ff_put_pixels_clamped(block, dest, line_size);
+}
+static void simple_idct_ARM_add(uint8_t *dest, int line_size, DCTELEM *block)
+{
+ simple_idct_ARM (block);
+ ff_add_pixels_clamped(block, dest, line_size);
+}
void dsputil_init_armv4l(DSPContext* c, AVCodecContext *avctx)
{
@@ -46,8 +57,14 @@ void dsputil_init_armv4l(DSPContext* c, AVCodecContext *avctx)
ff_add_pixels_clamped = c->add_pixels_clamped;
if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_ARM){
- c->idct_put= arm_idct_put;
- c->idct_add= arm_idct_add;
+ c->idct_put= j_rev_dct_ARM_put;
+ c->idct_add= j_rev_dct_ARM_add;
+ c->idct = j_rev_dct_ARM;
c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;/* FF_NO_IDCT_PERM */
+ } else if (idct_algo==FF_IDCT_SIMPLEARM){
+ c->idct_put= simple_idct_ARM_put;
+ c->idct_add= simple_idct_ARM_add;
+ c->idct = simple_idct_ARM;
+ c->idct_permutation_type= FF_NO_IDCT_PERM;
}
}
diff --git a/src/libffmpeg/libavcodec/asv1.c b/src/libffmpeg/libavcodec/asv1.c
new file mode 100644
index 000000000..2e6f785fb
--- /dev/null
+++ b/src/libffmpeg/libavcodec/asv1.c
@@ -0,0 +1,667 @@
+/*
+ * ASUS V1/V2 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 asv1.c
+ * ASUS V1/V2 codec.
+ */
+
+#include "avcodec.h"
+#include "dsputil.h"
+#include "mpegvideo.h"
+
+//#undef NDEBUG
+//#include <assert.h>
+
+#define VLC_BITS 6
+#define ASV2_LEVEL_VLC_BITS 10
+
+typedef struct ASV1Context{
+ AVCodecContext *avctx;
+ DSPContext dsp;
+ AVFrame picture;
+ PutBitContext pb;
+ GetBitContext gb;
+ ScanTable scantable;
+ int inv_qscale;
+ int mb_width;
+ int mb_height;
+ int mb_width2;
+ int mb_height2;
+ DCTELEM __align8 block[6][64];
+ uint16_t __align8 intra_matrix[64];
+ int __align8 q_intra_matrix[64];
+ uint8_t *bitstream_buffer;
+ int bitstream_buffer_size;
+} ASV1Context;
+
+static const uint8_t scantab[64]={
+ 0x00,0x08,0x01,0x09,0x10,0x18,0x11,0x19,
+ 0x02,0x0A,0x03,0x0B,0x12,0x1A,0x13,0x1B,
+ 0x04,0x0C,0x05,0x0D,0x20,0x28,0x21,0x29,
+ 0x06,0x0E,0x07,0x0F,0x14,0x1C,0x15,0x1D,
+ 0x22,0x2A,0x23,0x2B,0x30,0x38,0x31,0x39,
+ 0x16,0x1E,0x17,0x1F,0x24,0x2C,0x25,0x2D,
+ 0x32,0x3A,0x33,0x3B,0x26,0x2E,0x27,0x2F,
+ 0x34,0x3C,0x35,0x3D,0x36,0x3E,0x37,0x3F,
+};
+
+
+static const uint8_t reverse[256]={
+0x00,0x80,0x40,0xC0,0x20,0xA0,0x60,0xE0,0x10,0x90,0x50,0xD0,0x30,0xB0,0x70,0xF0,
+0x08,0x88,0x48,0xC8,0x28,0xA8,0x68,0xE8,0x18,0x98,0x58,0xD8,0x38,0xB8,0x78,0xF8,
+0x04,0x84,0x44,0xC4,0x24,0xA4,0x64,0xE4,0x14,0x94,0x54,0xD4,0x34,0xB4,0x74,0xF4,
+0x0C,0x8C,0x4C,0xCC,0x2C,0xAC,0x6C,0xEC,0x1C,0x9C,0x5C,0xDC,0x3C,0xBC,0x7C,0xFC,
+0x02,0x82,0x42,0xC2,0x22,0xA2,0x62,0xE2,0x12,0x92,0x52,0xD2,0x32,0xB2,0x72,0xF2,
+0x0A,0x8A,0x4A,0xCA,0x2A,0xAA,0x6A,0xEA,0x1A,0x9A,0x5A,0xDA,0x3A,0xBA,0x7A,0xFA,
+0x06,0x86,0x46,0xC6,0x26,0xA6,0x66,0xE6,0x16,0x96,0x56,0xD6,0x36,0xB6,0x76,0xF6,
+0x0E,0x8E,0x4E,0xCE,0x2E,0xAE,0x6E,0xEE,0x1E,0x9E,0x5E,0xDE,0x3E,0xBE,0x7E,0xFE,
+0x01,0x81,0x41,0xC1,0x21,0xA1,0x61,0xE1,0x11,0x91,0x51,0xD1,0x31,0xB1,0x71,0xF1,
+0x09,0x89,0x49,0xC9,0x29,0xA9,0x69,0xE9,0x19,0x99,0x59,0xD9,0x39,0xB9,0x79,0xF9,
+0x05,0x85,0x45,0xC5,0x25,0xA5,0x65,0xE5,0x15,0x95,0x55,0xD5,0x35,0xB5,0x75,0xF5,
+0x0D,0x8D,0x4D,0xCD,0x2D,0xAD,0x6D,0xED,0x1D,0x9D,0x5D,0xDD,0x3D,0xBD,0x7D,0xFD,
+0x03,0x83,0x43,0xC3,0x23,0xA3,0x63,0xE3,0x13,0x93,0x53,0xD3,0x33,0xB3,0x73,0xF3,
+0x0B,0x8B,0x4B,0xCB,0x2B,0xAB,0x6B,0xEB,0x1B,0x9B,0x5B,0xDB,0x3B,0xBB,0x7B,0xFB,
+0x07,0x87,0x47,0xC7,0x27,0xA7,0x67,0xE7,0x17,0x97,0x57,0xD7,0x37,0xB7,0x77,0xF7,
+0x0F,0x8F,0x4F,0xCF,0x2F,0xAF,0x6F,0xEF,0x1F,0x9F,0x5F,0xDF,0x3F,0xBF,0x7F,0xFF,
+};
+
+static const uint8_t ccp_tab[17][2]={
+ {0x2,2}, {0x7,5}, {0xB,5}, {0x3,5},
+ {0xD,5}, {0x5,5}, {0x9,5}, {0x1,5},
+ {0xE,5}, {0x6,5}, {0xA,5}, {0x2,5},
+ {0xC,5}, {0x4,5}, {0x8,5}, {0x3,2},
+ {0xF,5}, //EOB
+};
+
+static const uint8_t level_tab[7][2]={
+ {3,4}, {3,3}, {3,2}, {0,3}, {2,2}, {2,3}, {2,4}
+};
+
+static const uint8_t dc_ccp_tab[8][2]={
+ {0x1,2}, {0xD,4}, {0xF,4}, {0xC,4},
+ {0x5,3}, {0xE,4}, {0x4,3}, {0x0,2},
+};
+
+static const uint8_t ac_ccp_tab[16][2]={
+ {0x00,2}, {0x3B,6}, {0x0A,4}, {0x3A,6},
+ {0x02,3}, {0x39,6}, {0x3C,6}, {0x38,6},
+ {0x03,3}, {0x3D,6}, {0x08,4}, {0x1F,5},
+ {0x09,4}, {0x0B,4}, {0x0D,4}, {0x0C,4},
+};
+
+static const uint8_t asv2_level_tab[63][2]={
+ {0x3F,10},{0x2F,10},{0x37,10},{0x27,10},{0x3B,10},{0x2B,10},{0x33,10},{0x23,10},
+ {0x3D,10},{0x2D,10},{0x35,10},{0x25,10},{0x39,10},{0x29,10},{0x31,10},{0x21,10},
+ {0x1F, 8},{0x17, 8},{0x1B, 8},{0x13, 8},{0x1D, 8},{0x15, 8},{0x19, 8},{0x11, 8},
+ {0x0F, 6},{0x0B, 6},{0x0D, 6},{0x09, 6},
+ {0x07, 4},{0x05, 4},
+ {0x03, 2},
+ {0x00, 5},
+ {0x02, 2},
+ {0x04, 4},{0x06, 4},
+ {0x08, 6},{0x0C, 6},{0x0A, 6},{0x0E, 6},
+ {0x10, 8},{0x18, 8},{0x14, 8},{0x1C, 8},{0x12, 8},{0x1A, 8},{0x16, 8},{0x1E, 8},
+ {0x20,10},{0x30,10},{0x28,10},{0x38,10},{0x24,10},{0x34,10},{0x2C,10},{0x3C,10},
+ {0x22,10},{0x32,10},{0x2A,10},{0x3A,10},{0x26,10},{0x36,10},{0x2E,10},{0x3E,10},
+};
+
+
+static VLC ccp_vlc;
+static VLC level_vlc;
+static VLC dc_ccp_vlc;
+static VLC ac_ccp_vlc;
+static VLC asv2_level_vlc;
+
+static void init_vlcs(ASV1Context *a){
+ static int done = 0;
+
+ if (!done) {
+ done = 1;
+
+ init_vlc(&ccp_vlc, VLC_BITS, 17,
+ &ccp_tab[0][1], 2, 1,
+ &ccp_tab[0][0], 2, 1);
+ init_vlc(&dc_ccp_vlc, VLC_BITS, 8,
+ &dc_ccp_tab[0][1], 2, 1,
+ &dc_ccp_tab[0][0], 2, 1);
+ init_vlc(&ac_ccp_vlc, VLC_BITS, 16,
+ &ac_ccp_tab[0][1], 2, 1,
+ &ac_ccp_tab[0][0], 2, 1);
+ init_vlc(&level_vlc, VLC_BITS, 7,
+ &level_tab[0][1], 2, 1,
+ &level_tab[0][0], 2, 1);
+ init_vlc(&asv2_level_vlc, ASV2_LEVEL_VLC_BITS, 63,
+ &asv2_level_tab[0][1], 2, 1,
+ &asv2_level_tab[0][0], 2, 1);
+ }
+}
+
+//FIXME write a reversed bitstream reader to avoid the double reverse
+static inline int asv2_get_bits(GetBitContext *gb, int n){
+ return reverse[ get_bits(gb, n) << (8-n) ];
+}
+
+static inline void asv2_put_bits(PutBitContext *pb, int n, int v){
+ put_bits(pb, n, reverse[ v << (8-n) ]);
+}
+
+static inline int asv1_get_level(GetBitContext *gb){
+ int code= get_vlc2(gb, level_vlc.table, VLC_BITS, 1);
+
+ if(code==3) return get_sbits(gb, 8);
+ else return code - 3;
+}
+
+static inline int asv2_get_level(GetBitContext *gb){
+ int code= get_vlc2(gb, asv2_level_vlc.table, ASV2_LEVEL_VLC_BITS, 1);
+
+ if(code==31) return (int8_t)asv2_get_bits(gb, 8);
+ else return code - 31;
+}
+
+static inline void asv1_put_level(PutBitContext *pb, int level){
+ unsigned int index= level + 3;
+
+ if(index <= 6) put_bits(pb, level_tab[index][1], level_tab[index][0]);
+ else{
+ put_bits(pb, level_tab[3][1], level_tab[3][0]);
+ put_bits(pb, 8, level&0xFF);
+ }
+}
+
+static inline void asv2_put_level(PutBitContext *pb, int level){
+ unsigned int index= level + 31;
+
+ if(index <= 62) put_bits(pb, asv2_level_tab[index][1], asv2_level_tab[index][0]);
+ else{
+ put_bits(pb, asv2_level_tab[31][1], asv2_level_tab[31][0]);
+ asv2_put_bits(pb, 8, level&0xFF);
+ }
+}
+
+static inline int asv1_decode_block(ASV1Context *a, DCTELEM block[64]){
+ int i;
+
+ block[0]= 8*get_bits(&a->gb, 8);
+
+ for(i=0; i<11; i++){
+ const int ccp= get_vlc2(&a->gb, ccp_vlc.table, VLC_BITS, 1);
+
+ if(ccp){
+ if(ccp == 16) break;
+ if(ccp < 0 || i>=10){
+ printf("coded coeff pattern damaged\n");
+ return -1;
+ }
+
+ if(ccp&8) block[a->scantable.permutated[4*i+0]]= (asv1_get_level(&a->gb) * a->intra_matrix[4*i+0])>>4;
+ if(ccp&4) block[a->scantable.permutated[4*i+1]]= (asv1_get_level(&a->gb) * a->intra_matrix[4*i+1])>>4;
+ if(ccp&2) block[a->scantable.permutated[4*i+2]]= (asv1_get_level(&a->gb) * a->intra_matrix[4*i+2])>>4;
+ if(ccp&1) block[a->scantable.permutated[4*i+3]]= (asv1_get_level(&a->gb) * a->intra_matrix[4*i+3])>>4;
+ }
+ }
+
+ return 0;
+}
+
+static inline int asv2_decode_block(ASV1Context *a, DCTELEM block[64]){
+ int i, count, ccp;
+
+ count= asv2_get_bits(&a->gb, 4);
+
+ block[0]= 8*asv2_get_bits(&a->gb, 8);
+
+ ccp= get_vlc2(&a->gb, dc_ccp_vlc.table, VLC_BITS, 1);
+ if(ccp){
+ if(ccp&4) block[a->scantable.permutated[1]]= (asv2_get_level(&a->gb) * a->intra_matrix[1])>>4;
+ if(ccp&2) block[a->scantable.permutated[2]]= (asv2_get_level(&a->gb) * a->intra_matrix[2])>>4;
+ if(ccp&1) block[a->scantable.permutated[3]]= (asv2_get_level(&a->gb) * a->intra_matrix[3])>>4;
+ }
+
+ for(i=1; i<count+1; i++){
+ const int ccp= get_vlc2(&a->gb, ac_ccp_vlc.table, VLC_BITS, 1);
+
+ if(ccp){
+ if(ccp&8) block[a->scantable.permutated[4*i+0]]= (asv2_get_level(&a->gb) * a->intra_matrix[4*i+0])>>4;
+ if(ccp&4) block[a->scantable.permutated[4*i+1]]= (asv2_get_level(&a->gb) * a->intra_matrix[4*i+1])>>4;
+ if(ccp&2) block[a->scantable.permutated[4*i+2]]= (asv2_get_level(&a->gb) * a->intra_matrix[4*i+2])>>4;
+ if(ccp&1) block[a->scantable.permutated[4*i+3]]= (asv2_get_level(&a->gb) * a->intra_matrix[4*i+3])>>4;
+ }
+ }
+
+ return 0;
+}
+
+static inline void asv1_encode_block(ASV1Context *a, DCTELEM block[64]){
+ int i;
+ int nc_count=0;
+
+ put_bits(&a->pb, 8, (block[0] + 32)>>6);
+ block[0]= 0;
+
+ for(i=0; i<10; i++){
+ const int index= scantab[4*i];
+ int ccp=0;
+
+ if( (block[index + 0] = (block[index + 0]*a->q_intra_matrix[index + 0] + (1<<15))>>16) ) ccp |= 8;
+ if( (block[index + 8] = (block[index + 8]*a->q_intra_matrix[index + 8] + (1<<15))>>16) ) ccp |= 4;
+ if( (block[index + 1] = (block[index + 1]*a->q_intra_matrix[index + 1] + (1<<15))>>16) ) ccp |= 2;
+ if( (block[index + 9] = (block[index + 9]*a->q_intra_matrix[index + 9] + (1<<15))>>16) ) ccp |= 1;
+
+ if(ccp){
+ for(;nc_count; nc_count--)
+ put_bits(&a->pb, ccp_tab[0][1], ccp_tab[0][0]);
+
+ put_bits(&a->pb, ccp_tab[ccp][1], ccp_tab[ccp][0]);
+
+ if(ccp&8) asv1_put_level(&a->pb, block[index + 0]);
+ if(ccp&4) asv1_put_level(&a->pb, block[index + 8]);
+ if(ccp&2) asv1_put_level(&a->pb, block[index + 1]);
+ if(ccp&1) asv1_put_level(&a->pb, block[index + 9]);
+ }else{
+ nc_count++;
+ }
+ }
+ put_bits(&a->pb, ccp_tab[16][1], ccp_tab[16][0]);
+}
+
+static inline void asv2_encode_block(ASV1Context *a, DCTELEM block[64]){
+ int i;
+ int count=0;
+
+ for(count=63; count>3; count--){
+ const int index= scantab[count];
+
+ if( (block[index]*a->q_intra_matrix[index] + (1<<15))>>16 )
+ break;
+ }
+
+ count >>= 2;
+
+ asv2_put_bits(&a->pb, 4, count);
+ asv2_put_bits(&a->pb, 8, (block[0] + 32)>>6);
+ block[0]= 0;
+
+ for(i=0; i<=count; i++){
+ const int index= scantab[4*i];
+ int ccp=0;
+
+ if( (block[index + 0] = (block[index + 0]*a->q_intra_matrix[index + 0] + (1<<15))>>16) ) ccp |= 8;
+ if( (block[index + 8] = (block[index + 8]*a->q_intra_matrix[index + 8] + (1<<15))>>16) ) ccp |= 4;
+ if( (block[index + 1] = (block[index + 1]*a->q_intra_matrix[index + 1] + (1<<15))>>16) ) ccp |= 2;
+ if( (block[index + 9] = (block[index + 9]*a->q_intra_matrix[index + 9] + (1<<15))>>16) ) ccp |= 1;
+
+ if(i) put_bits(&a->pb, ac_ccp_tab[ccp][1], ac_ccp_tab[ccp][0]);
+ else put_bits(&a->pb, dc_ccp_tab[ccp][1], dc_ccp_tab[ccp][0]);
+
+ if(ccp){
+ if(ccp&8) asv2_put_level(&a->pb, block[index + 0]);
+ if(ccp&4) asv2_put_level(&a->pb, block[index + 8]);
+ if(ccp&2) asv2_put_level(&a->pb, block[index + 1]);
+ if(ccp&1) asv2_put_level(&a->pb, block[index + 9]);
+ }
+ }
+}
+
+static inline int decode_mb(ASV1Context *a, DCTELEM block[6][64]){
+ int i;
+
+ a->dsp.clear_blocks(block[0]);
+
+ if(a->avctx->codec_id == CODEC_ID_ASV1){
+ for(i=0; i<6; i++){
+ if( asv1_decode_block(a, block[i]) < 0)
+ return -1;
+ }
+ }else{
+ for(i=0; i<6; i++){
+ if( asv2_decode_block(a, block[i]) < 0)
+ return -1;
+ }
+ }
+ return 0;
+}
+
+static inline void encode_mb(ASV1Context *a, DCTELEM block[6][64]){
+ int i;
+
+ if(a->avctx->codec_id == CODEC_ID_ASV1){
+ for(i=0; i<6; i++)
+ asv1_encode_block(a, block[i]);
+ }else{
+ for(i=0; i<6; i++)
+ asv2_encode_block(a, block[i]);
+ }
+}
+
+static inline void idct_put(ASV1Context *a, int mb_x, int mb_y){
+ DCTELEM (*block)[64]= a->block;
+ int linesize= a->picture.linesize[0];
+
+ uint8_t *dest_y = a->picture.data[0] + (mb_y * 16* linesize ) + mb_x * 16;
+ uint8_t *dest_cb = a->picture.data[1] + (mb_y * 8 * a->picture.linesize[1]) + mb_x * 8;
+ uint8_t *dest_cr = a->picture.data[2] + (mb_y * 8 * a->picture.linesize[2]) + mb_x * 8;
+
+ a->dsp.idct_put(dest_y , linesize, block[0]);
+ a->dsp.idct_put(dest_y + 8, linesize, block[1]);
+ a->dsp.idct_put(dest_y + 8*linesize , linesize, block[2]);
+ a->dsp.idct_put(dest_y + 8*linesize + 8, linesize, block[3]);
+
+ if(!(a->avctx->flags&CODEC_FLAG_GRAY)){
+ a->dsp.idct_put(dest_cb, a->picture.linesize[1], block[4]);
+ a->dsp.idct_put(dest_cr, a->picture.linesize[2], block[5]);
+ }
+}
+
+static inline void dct_get(ASV1Context *a, int mb_x, int mb_y){
+ DCTELEM (*block)[64]= a->block;
+ int linesize= a->picture.linesize[0];
+ int i;
+
+ uint8_t *ptr_y = a->picture.data[0] + (mb_y * 16* linesize ) + mb_x * 16;
+ uint8_t *ptr_cb = a->picture.data[1] + (mb_y * 8 * a->picture.linesize[1]) + mb_x * 8;
+ uint8_t *ptr_cr = a->picture.data[2] + (mb_y * 8 * a->picture.linesize[2]) + mb_x * 8;
+
+ a->dsp.get_pixels(block[0], ptr_y , linesize);
+ a->dsp.get_pixels(block[1], ptr_y + 8, linesize);
+ a->dsp.get_pixels(block[2], ptr_y + 8*linesize , linesize);
+ a->dsp.get_pixels(block[3], ptr_y + 8*linesize + 8, linesize);
+ for(i=0; i<4; i++)
+ a->dsp.fdct(block[i]);
+
+ if(!(a->avctx->flags&CODEC_FLAG_GRAY)){
+ a->dsp.get_pixels(block[4], ptr_cb, a->picture.linesize[1]);
+ a->dsp.get_pixels(block[5], ptr_cr, a->picture.linesize[2]);
+ for(i=4; i<6; i++)
+ a->dsp.fdct(block[i]);
+ }
+}
+
+static int decode_frame(AVCodecContext *avctx,
+ void *data, int *data_size,
+ uint8_t *buf, int buf_size)
+{
+ ASV1Context * const a = avctx->priv_data;
+ AVFrame *picture = data;
+ AVFrame * const p= (AVFrame*)&a->picture;
+ int mb_x, mb_y;
+
+ *data_size = 0;
+
+ /* special case for last picture */
+ if (buf_size == 0) {
+ return 0;
+ }
+
+ if(p->data[0])
+ avctx->release_buffer(avctx, p);
+
+ p->reference= 0;
+ if(avctx->get_buffer(avctx, p) < 0){
+ fprintf(stderr, "get_buffer() failed\n");
+ return -1;
+ }
+ p->pict_type= I_TYPE;
+ p->key_frame= 1;
+
+ a->bitstream_buffer= av_fast_realloc(a->bitstream_buffer, &a->bitstream_buffer_size, buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
+
+ if(avctx->codec_id == CODEC_ID_ASV1)
+ a->dsp.bswap_buf((uint32_t*)a->bitstream_buffer, (uint32_t*)buf, buf_size/4);
+ else{
+ int i;
+ for(i=0; i<buf_size; i++)
+ a->bitstream_buffer[i]= reverse[ buf[i] ];
+ }
+
+ init_get_bits(&a->gb, a->bitstream_buffer, buf_size*8);
+
+ for(mb_y=0; mb_y<a->mb_height2; mb_y++){
+ for(mb_x=0; mb_x<a->mb_width2; mb_x++){
+ if( decode_mb(a, a->block) <0)
+ return -1;
+
+ idct_put(a, mb_x, mb_y);
+ }
+ }
+
+ if(a->mb_width2 != a->mb_width){
+ mb_x= a->mb_width2;
+ for(mb_y=0; mb_y<a->mb_height2; mb_y++){
+ if( decode_mb(a, a->block) <0)
+ return -1;
+
+ idct_put(a, mb_x, mb_y);
+ }
+ }
+
+ if(a->mb_height2 != a->mb_height){
+ mb_y= a->mb_height2;
+ for(mb_x=0; mb_x<a->mb_width; mb_x++){
+ if( decode_mb(a, a->block) <0)
+ return -1;
+
+ idct_put(a, mb_x, mb_y);
+ }
+ }
+#if 0
+int i;
+printf("%d %d\n", 8*buf_size, get_bits_count(&a->gb));
+for(i=get_bits_count(&a->gb); i<8*buf_size; i++){
+ printf("%d", get_bits1(&a->gb));
+}
+
+for(i=0; i<s->avctx->extradata_size; i++){
+ printf("%c\n", ((uint8_t*)s->avctx->extradata)[i]);
+}
+#endif
+
+ *picture= *(AVFrame*)&a->picture;
+ *data_size = sizeof(AVPicture);
+
+ emms_c();
+
+ return (get_bits_count(&a->gb)+31)/32*4;
+}
+
+static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){
+ ASV1Context * const a = avctx->priv_data;
+ AVFrame *pict = data;
+ AVFrame * const p= (AVFrame*)&a->picture;
+ int size;
+ int mb_x, mb_y;
+
+ init_put_bits(&a->pb, buf, buf_size);
+
+ *p = *pict;
+ p->pict_type= I_TYPE;
+ p->key_frame= 1;
+
+ for(mb_y=0; mb_y<a->mb_height2; mb_y++){
+ for(mb_x=0; mb_x<a->mb_width2; mb_x++){
+ dct_get(a, mb_x, mb_y);
+ encode_mb(a, a->block);
+ }
+ }
+
+ if(a->mb_width2 != a->mb_width){
+ mb_x= a->mb_width2;
+ for(mb_y=0; mb_y<a->mb_height2; mb_y++){
+ dct_get(a, mb_x, mb_y);
+ encode_mb(a, a->block);
+ }
+ }
+
+ if(a->mb_height2 != a->mb_height){
+ mb_y= a->mb_height2;
+ for(mb_x=0; mb_x<a->mb_width; mb_x++){
+ dct_get(a, mb_x, mb_y);
+ encode_mb(a, a->block);
+ }
+ }
+ emms_c();
+
+ align_put_bits(&a->pb);
+ while(get_bit_count(&a->pb)&31)
+ put_bits(&a->pb, 8, 0);
+
+ size= get_bit_count(&a->pb)/32;
+
+ if(avctx->codec_id == CODEC_ID_ASV1)
+ a->dsp.bswap_buf((uint32_t*)buf, (uint32_t*)buf, size);
+ else{
+ int i;
+ for(i=0; i<4*size; i++)
+ buf[i]= reverse[ buf[i] ];
+ }
+
+ return size*4;
+}
+
+static void common_init(AVCodecContext *avctx){
+ ASV1Context * const a = avctx->priv_data;
+
+ dsputil_init(&a->dsp, avctx);
+
+ a->mb_width = (avctx->width + 15) / 16;
+ a->mb_height = (avctx->height + 15) / 16;
+ a->mb_width2 = (avctx->width + 0) / 16;
+ a->mb_height2 = (avctx->height + 0) / 16;
+
+ avctx->coded_frame= (AVFrame*)&a->picture;
+ a->avctx= avctx;
+}
+
+static int decode_init(AVCodecContext *avctx){
+ ASV1Context * const a = avctx->priv_data;
+ AVFrame *p= (AVFrame*)&a->picture;
+ int i;
+ const int scale= avctx->codec_id == CODEC_ID_ASV1 ? 1 : 2;
+
+ common_init(avctx);
+ init_vlcs(a);
+ ff_init_scantable(a->dsp.idct_permutation, &a->scantable, scantab);
+
+ a->inv_qscale= ((uint8_t*)avctx->extradata)[0];
+ if(a->inv_qscale == 0){
+ printf("illegal qscale 0\n");
+ if(avctx->codec_id == CODEC_ID_ASV1)
+ a->inv_qscale= 6;
+ else
+ a->inv_qscale= 10;
+ }
+
+ for(i=0; i<64; i++){
+ int index= scantab[i];
+
+ a->intra_matrix[i]= 64*scale*ff_mpeg1_default_intra_matrix[index] / a->inv_qscale;
+ }
+
+ p->qstride= a->mb_width;
+ p->qscale_table= av_mallocz( p->qstride * a->mb_height);
+ p->quality= (32*scale + a->inv_qscale/2)/a->inv_qscale;
+ memset(p->qscale_table, p->quality, p->qstride*a->mb_height);
+
+ return 0;
+}
+
+static int encode_init(AVCodecContext *avctx){
+ ASV1Context * const a = avctx->priv_data;
+ int i;
+ const int scale= avctx->codec_id == CODEC_ID_ASV1 ? 1 : 2;
+
+ common_init(avctx);
+
+ if(avctx->global_quality == 0) avctx->global_quality= 4*FF_QUALITY_SCALE;
+
+ a->inv_qscale= (32*scale*FF_QUALITY_SCALE + avctx->global_quality/2) / avctx->global_quality;
+
+ avctx->extradata= av_mallocz(8);
+ avctx->extradata_size=8;
+ ((uint32_t*)avctx->extradata)[0]= le2me_32(a->inv_qscale);
+ ((uint32_t*)avctx->extradata)[1]= le2me_32(ff_get_fourcc("ASUS"));
+
+ for(i=0; i<64; i++){
+ int q= 32*scale*ff_mpeg1_default_intra_matrix[i];
+ a->q_intra_matrix[i]= ((a->inv_qscale<<16) + q/2) / q;
+ }
+
+ return 0;
+}
+
+static int decode_end(AVCodecContext *avctx){
+ ASV1Context * const a = avctx->priv_data;
+
+ av_freep(&a->bitstream_buffer);
+ av_freep(&a->picture.qscale_table);
+ a->bitstream_buffer_size=0;
+
+ avcodec_default_free_buffers(avctx);
+
+ return 0;
+}
+
+AVCodec asv1_decoder = {
+ "asv1",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_ASV1,
+ sizeof(ASV1Context),
+ decode_init,
+ NULL,
+ decode_end,
+ decode_frame,
+ CODEC_CAP_DR1,
+};
+
+AVCodec asv2_decoder = {
+ "asv2",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_ASV2,
+ sizeof(ASV1Context),
+ decode_init,
+ NULL,
+ decode_end,
+ decode_frame,
+ CODEC_CAP_DR1,
+};
+
+#ifdef CONFIG_ENCODERS
+
+AVCodec asv1_encoder = {
+ "asv1",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_ASV1,
+ sizeof(ASV1Context),
+ encode_init,
+ encode_frame,
+ //encode_end,
+};
+
+AVCodec asv2_encoder = {
+ "asv2",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_ASV2,
+ sizeof(ASV1Context),
+ encode_init,
+ encode_frame,
+ //encode_end,
+};
+
+#endif //CONFIG_ENCODERS
diff --git a/src/libffmpeg/libavcodec/avcodec.c b/src/libffmpeg/libavcodec/avcodec.c
new file mode 100644
index 000000000..4f687568b
--- /dev/null
+++ b/src/libffmpeg/libavcodec/avcodec.c
@@ -0,0 +1,172 @@
+/**
+ * @file avcodec.c
+ * avcodec.
+ */
+
+#include "errno.h"
+#include "avcodec.h"
+
+#ifndef MKTAG
+#define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24))
+#endif
+
+// private structure used to hide all internal memory allocations
+// and structures used for de/encoding - end user should
+// never see any complicated structure
+typedef struct private_handle
+{
+ AVCodec* avcodec;
+ AVCodecContext avcontext;
+ struct private_handle* next;
+ struct private_handle* prev;
+} private_handle_t;
+
+static private_handle_t* handle_first = 0;
+
+static AVCodec* avcodec_find_by_fcc(uint32_t fcc)
+{
+ // translation table
+ static const struct fcc_to_avcodecid {
+ enum CodecID codec;
+ uint32_t list[4]; // maybe we could map more fcc to same codec
+ } lc[] = {
+ { CODEC_ID_H263, { MKTAG('U', '2', '6', '3'), 0 } },
+ { CODEC_ID_H263I, { MKTAG('I', '2', '6', '3'), 0 } },
+ { CODEC_ID_MSMPEG4V3, { MKTAG('D', 'I', 'V', '3'), 0 } },
+ { CODEC_ID_MPEG4, { MKTAG('D', 'I', 'V', 'X'), MKTAG('D', 'X', '5', '0'), 0 } },
+ { CODEC_ID_MSMPEG4V2, { MKTAG('M', 'P', '4', '2'), 0 } },
+ { CODEC_ID_MJPEG, { MKTAG('M', 'J', 'P', 'G'), 0 } },
+ { CODEC_ID_MPEG1VIDEO, { MKTAG('P', 'I', 'M', '1'), 0 } },
+ { CODEC_ID_AC3, { 0x2000, 0 } },
+ { CODEC_ID_MP2, { 0x50, 0x55, 0 } },
+ { CODEC_ID_FLV1, { MKTAG('F', 'L', 'V', '1'), 0 } },
+
+ { CODEC_ID_NONE, {0}}
+ };
+ const struct fcc_to_avcodecid* c;
+
+ for (c = lc; c->codec != CODEC_ID_NONE; c++)
+ {
+ int i = 0;
+ while (c->list[i] != 0)
+ if (c->list[i++] == fcc)
+ return avcodec_find_decoder(c->codec);
+ }
+
+ return NULL;
+}
+
+static private_handle_t* create_handle(void)
+{
+ private_handle_t* t = av_malloc(sizeof(private_handle_t));
+ if (!t)
+ return NULL;
+ memset(t, 0, sizeof(*t));
+
+ // register and fill
+ if (!handle_first)
+ {
+ avcodec_init();
+ avcodec_register_all();
+ handle_first = t;
+ }
+ else
+ {
+ t->prev = handle_first->next;
+ handle_first->next = t;
+ t->next = handle_first;
+ }
+
+ return t;
+}
+
+static void destroy_handle(private_handle_t* handle)
+{
+ if (handle)
+ {
+ if (handle->avcodec)
+ {
+ avcodec_close(&handle->avcontext);
+ }
+ av_free(handle);
+
+ // count referencies
+ }
+}
+
+int avcodec(void* handle, avc_cmd_t cmd, void* pin, void* pout)
+{
+ AVCodecContext* ctx = handle;
+ switch (cmd)
+ {
+ case AVC_OPEN_BY_NAME:
+ {
+ // pin char* codec name
+ private_handle_t* h = create_handle();
+ (private_handle_t**)pout = h;
+ if (!h)
+ return -ENOMEM;
+ if (!h->avcodec)
+ {
+ destroy_handle(h);
+ (private_handle_t**)pout = NULL;
+ return -1;// better error
+ }
+ return 0;
+ }
+ case AVC_OPEN_BY_CODEC_ID:
+ {
+ // pin uint32_t codec fourcc
+ private_handle_t* h = create_handle();
+ (private_handle_t**)pout = h;
+ if (!h)
+ return -ENOMEM;
+
+ if (!h->avcodec)
+ {
+ destroy_handle(h);
+ (private_handle_t**)pout = NULL;
+ return -1;// better error
+ }
+ return 0;
+ }
+ case AVC_OPEN_BY_FOURCC:
+ {
+ // pin uint32_t codec fourcc
+ private_handle_t* h = create_handle();
+ (private_handle_t**)pout = h;
+ if (!h)
+ return -ENOMEM;
+ h->avcodec = avcodec_find_by_fcc((uint32_t) pin);
+ if (!h->avcodec)
+ {
+ destroy_handle(h);
+ (private_handle_t**)pout = NULL;
+ return -1;// better error
+ }
+ return 0;
+ }
+ case AVC_CLOSE:
+ // uninit part
+ // eventually close all allocated space if this was last
+ // instance
+ destroy_handle(handle);
+ break;
+
+ case AVC_FLUSH:
+ break;
+
+ case AVC_DECODE:
+ break;
+
+ case AVC_ENCODE:
+ break;
+
+ case AVC_GET_VERSION:
+ (int*) pout = 500;
+ default:
+ return -1;
+
+ }
+ return 0;
+}
diff --git a/src/libffmpeg/libavcodec/avcodec.h b/src/libffmpeg/libavcodec/avcodec.h
index 6daf668c6..47ab4c095 100644
--- a/src/libffmpeg/libavcodec/avcodec.h
+++ b/src/libffmpeg/libavcodec/avcodec.h
@@ -12,26 +12,34 @@ extern "C" {
#endif
#include "common.h"
+#include "rational.h"
-#define LIBAVCODEC_VERSION_INT 0x000406
-#define LIBAVCODEC_VERSION "0.4.6"
-#define LIBAVCODEC_BUILD 4669
-#define LIBAVCODEC_BUILD_STR "4669"
+#define FFMPEG_VERSION_INT 0x000408
+#define FFMPEG_VERSION "0.4.8"
+#define LIBAVCODEC_BUILD 4687
-#define LIBAVCODEC_IDENT "FFmpeg" LIBAVCODEC_VERSION "b" LIBAVCODEC_BUILD_STR
+#define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT
+#define LIBAVCODEC_VERSION FFMPEG_VERSION
+
+#define AV_STRINGIFY(s) AV_TOSTRING(s)
+#define AV_TOSTRING(s) #s
+#define LIBAVCODEC_IDENT "FFmpeg" LIBAVCODEC_VERSION "b" AV_STRINGIFY(LIBAVCODEC_BUILD)
enum CodecID {
CODEC_ID_NONE,
CODEC_ID_MPEG1VIDEO,
+ CODEC_ID_MPEG2VIDEO, /* prefered ID for MPEG Video 1 or 2 decoding */
+ CODEC_ID_MPEG2VIDEO_XVMC,
CODEC_ID_H263,
CODEC_ID_RV10,
CODEC_ID_MP2,
- CODEC_ID_MP3LAME,
+ CODEC_ID_MP3, /* prefered ID for MPEG Audio layer 1, 2 or3 decoding */
CODEC_ID_VORBIS,
CODEC_ID_AC3,
CODEC_ID_MJPEG,
CODEC_ID_MJPEGB,
CODEC_ID_LJPEG,
+ CODEC_ID_SP5X,
CODEC_ID_MPEG4,
CODEC_ID_RAWVIDEO,
CODEC_ID_MSMPEG4V1,
@@ -41,6 +49,7 @@ enum CodecID {
CODEC_ID_WMV2,
CODEC_ID_H263P,
CODEC_ID_H263I,
+ CODEC_ID_FLV1,
CODEC_ID_SVQ1,
CODEC_ID_SVQ3,
CODEC_ID_DVVIDEO,
@@ -54,11 +63,26 @@ enum CodecID {
CODEC_ID_H264,
CODEC_ID_INDEO3,
CODEC_ID_VP3,
+ CODEC_ID_THEORA,
CODEC_ID_AAC,
CODEC_ID_MPEG4AAC,
CODEC_ID_ASV1,
+ CODEC_ID_ASV2,
CODEC_ID_FFV1,
CODEC_ID_4XM,
+ CODEC_ID_VCR1,
+ CODEC_ID_CLJR,
+ CODEC_ID_MDEC,
+ CODEC_ID_ROQ,
+ CODEC_ID_INTERPLAY_VIDEO,
+ CODEC_ID_XAN_WC3,
+ CODEC_ID_XAN_WC4,
+ CODEC_ID_RPZA,
+ CODEC_ID_CINEPAK,
+ CODEC_ID_WS_VQA,
+ CODEC_ID_MSRLE,
+ CODEC_ID_MSVIDEO1,
+ CODEC_ID_IDCIN,
/* various pcm "codecs" */
CODEC_ID_PCM_S16LE,
@@ -73,16 +97,31 @@ enum CodecID {
/* various adpcm codecs */
CODEC_ID_ADPCM_IMA_QT,
CODEC_ID_ADPCM_IMA_WAV,
+ CODEC_ID_ADPCM_IMA_DK3,
+ CODEC_ID_ADPCM_IMA_DK4,
+ CODEC_ID_ADPCM_IMA_WS,
CODEC_ID_ADPCM_MS,
CODEC_ID_ADPCM_4XM,
+ CODEC_ID_ADPCM_XA,
+ CODEC_ID_ADPCM_ADX,
/* AMR */
CODEC_ID_AMR_NB,
+ CODEC_ID_AMR_WB,
+
/* RealAudio codecs*/
CODEC_ID_RA_144,
CODEC_ID_RA_288,
+
+ /* various DPCM codecs */
+ CODEC_ID_ROQ_DPCM,
+ CODEC_ID_INTERPLAY_DPCM,
+ CODEC_ID_XAN_DPCM,
};
+/* CODEC_ID_MP3LAME is absolete */
+#define CODEC_ID_MP3LAME CODEC_ID_MP3
+
enum CodecType {
CODEC_TYPE_UNKNOWN = -1,
CODEC_TYPE_VIDEO,
@@ -90,7 +129,22 @@ enum CodecType {
};
/**
- * Pixel format.
+ * Pixel format. Notes:
+ *
+ * PIX_FMT_RGBA32 is handled in an endian-specific manner. A RGBA
+ * color is put together as:
+ * (A << 24) | (R << 16) | (G << 8) | B
+ * This is stored as BGRA on little endian CPU architectures and ARGB on
+ * big endian CPUs.
+ *
+ * When the pixel format is palettized RGB (PIX_FMT_PAL8), the palettized
+ * image data is stored in AVFrame.data[0]. The palette is transported in
+ * AVFrame.data[1] and, is 1024 bytes long (256 4-byte entries) and is
+ * formatted the same as in PIX_FMT_RGBA32 described above (i.e., it is
+ * also endian-specific). Note also that the individual RGB palette
+ * components stored in AVFrame.data[1] should be in the range 0..255.
+ * This is important as many custom PAL8 video codecs that were designed
+ * to run on the IBM VGA graphics adapter use 6-bit palette components.
*/
enum PixelFormat {
PIX_FMT_YUV420P, ///< Planar YUV 4:2:0 (1 Cr & Cb sample per 2x2 Y samples)
@@ -99,7 +153,7 @@ enum PixelFormat {
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, ///< Packed pixel, 4 bytes per pixel, BGRABGRA...
+ PIX_FMT_RGBA32, ///< Packed pixel, 4 bytes per pixel, BGRABGRA..., stored in cpu endianness
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
@@ -111,6 +165,8 @@ enum PixelFormat {
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_XVMC_MPEG2_MC,///< XVideo Motion Acceleration via common packet passing(xvmc_render.h)
+ PIX_FMT_XVMC_MPEG2_IDCT,
PIX_FMT_NB,
};
@@ -152,8 +208,9 @@ typedef struct RcOverride{
extern int motion_estimation_method;
/* ME algos sorted by quality */
-static const int Motion_Est_QTab[] = { ME_ZERO, ME_PHODS, ME_LOG,
- ME_X1, ME_EPZS, ME_FULL };
+//FIXME remove IMHO
+static const __attribute__((unused)) int Motion_Est_QTab[] =
+ { ME_ZERO, ME_PHODS, ME_LOG, ME_X1, ME_EPZS, ME_FULL };
#define FF_MAX_B_FRAMES 8
@@ -163,11 +220,11 @@ static const int Motion_Est_QTab[] = { ME_ZERO, ME_PHODS, ME_LOG,
Note: note not everything is supported yet
*/
-#define CODEC_FLAG_HQ 0x0001 ///< brute force MB-type decission mode (slow)
#define CODEC_FLAG_QSCALE 0x0002 ///< use fixed qscale
#define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed
#define CODEC_FLAG_QPEL 0x0010 ///< use qpel MC
#define CODEC_FLAG_GMC 0x0020 ///< use GMC
+#define CODEC_FLAG_MV0 0x0040 ///< always try a MB with MV=<0,0>
#define CODEC_FLAG_PART 0x0080 ///< use data partitioning
/* parent program gurantees that the input for b-frame containing streams is not written to
for at least s->max_b_frames+1 frames, if this is not set than the input will be copied */
@@ -182,14 +239,16 @@ static const int Motion_Est_QTab[] = { ME_ZERO, ME_PHODS, ME_LOG,
of only at frame boundaries */
#define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< normalize adaptive quantization
#define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< use interlaced dct
-#define CODEC_FLAG_LOW_DELAY 0x00080000 ///< force low delay / will fail on b frames
+#define CODEC_FLAG_LOW_DELAY 0x00080000 ///< force low delay
#define CODEC_FLAG_ALT_SCAN 0x00100000 ///< use alternate scan
#define CODEC_FLAG_TRELLIS_QUANT 0x00200000 ///< use trellis quantization
#define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< place global headers in extradata instead of every keyframe
#define CODEC_FLAG_BITEXACT 0x00800000 ///< use only bitexact stuff (except (i)dct)
/* Fx : Flag for h263+ extra options */
-#define CODEC_FLAG_H263P_AIC 0x01000000 ///< Advanced intra coding
+#define CODEC_FLAG_H263P_AIC 0x01000000 ///< H263 Advanced intra coding / MPEG4 AC prediction (remove this)
+#define CODEC_FLAG_AC_PRED 0x01000000 ///< H263 Advanced intra coding / MPEG4 AC prediction
#define CODEC_FLAG_H263P_UMV 0x02000000 ///< Unlimited motion vector
+#define CODEC_FLAG_CBP_RD 0x04000000 ///< use rate distortion optimization for cbp
/* For advanced prediction mode, we reuse the 4MV flag */
/* Unsupported options :
* Syntax Arithmetic coding (SAC)
@@ -213,6 +272,34 @@ static const int Motion_Est_QTab[] = { ME_ZERO, ME_PHODS, ME_LOG,
#define CODEC_CAP_PARSE_ONLY 0x0004
#define CODEC_CAP_TRUNCATED 0x0008
+/**
+ * Pan Scan area.
+ * this specifies the area which should be displayed. Note there may be multiple such areas for one frame
+ */
+typedef struct AVPanScan{
+ /**
+ * id.
+ * - encoding: set by user.
+ * - decoding: set by lavc
+ */
+ int id;
+
+ /**
+ * width and height in 1/16 pel
+ * - encoding: set by user.
+ * - decoding: set by lavc
+ */
+ int width;
+ int height;
+
+ /**
+ * position of the top left corner in 1/16 pel for up to 3 fields/frames.
+ * - encoding: set by user.
+ * - decoding: set by lavc
+ */
+ int16_t position[3][2];
+}AVPanScan;
+
#define FF_COMMON_FRAME \
/**\
* pointer to the picture planes.\
@@ -265,15 +352,15 @@ static const int Motion_Est_QTab[] = { ME_ZERO, ME_PHODS, ME_LOG,
int display_picture_number;\
\
/**\
- * quality (between 1 (good) and 31 (bad)) \
+ * quality (between 1 (good) and FF_LAMBDA_MAX (bad)) \
* - encoding: set by lavc for coded_picture (and set by user for input)\
* - decoding: set by lavc\
*/\
- float quality; \
+ int quality; \
\
/**\
* buffer age (1->was last buffer and dint change, 2->..., ...).\
- * set to something large if the buffer has not been used yet \
+ * set to INT_MAX if the buffer has not been used yet \
* - encoding: unused\
* - decoding: MUST be set by get_buffer()\
*/\
@@ -341,13 +428,36 @@ static const int Motion_Est_QTab[] = { ME_ZERO, ME_PHODS, ME_LOG,
* \
*/\
int qscale_type;\
+ \
+ /**\
+ * The content of the picture is interlaced.\
+ * - encoding: set by user\
+ * - decoding: set by lavc (default 0)\
+ */\
+ int interlaced_frame;\
+ \
+ /**\
+ * if the content is interlaced, is top field displayed first.\
+ * - encoding: set by user\
+ * - decoding: set by lavc\
+ */\
+ int top_field_first;\
+ \
+ /**\
+ * Pan scan.\
+ * - encoding: set by user\
+ * - decoding: set by lavc\
+ */\
+ AVPanScan *pan_scan;\
+
#define FF_QSCALE_TYPE_MPEG1 0
#define FF_QSCALE_TYPE_MPEG2 1
#define FF_BUFFER_TYPE_INTERNAL 1
-#define FF_BUFFER_TYPE_USER 2 ///< Direct rendering buffers
-#define FF_BUFFER_TYPE_SHARED 4 ///< buffer from somewher else, dont dealloc
+#define FF_BUFFER_TYPE_USER 2 ///< Direct rendering buffers (image is (de)allocated by user)
+#define FF_BUFFER_TYPE_SHARED 4 ///< buffer from somewher else, dont dealloc image (data/base)
+#define FF_BUFFER_TYPE_COPY 8 ///< just a (modified) copy of some other buffer, dont dealloc anything
#define FF_I_TYPE 1 // Intra
@@ -430,7 +540,7 @@ typedef struct AVCodecContext {
/**
* width / height.
* - encoding: MUST be set by user.
- * - decoding: set by user, some codecs might override / change it during playback
+ * - decoding: set by user if known, codec should override / dynamically change if needed
*/
int width, height;
@@ -450,7 +560,10 @@ typedef struct AVCodecContext {
/**
* pixel format, see PIX_FMT_xxx.
- * - encoding: unused
+ * - encoding: FIXME: used by ffmpeg to decide whether an pix_fmt
+ * conversion is in order. This only works for
+ * codecs with one supported pix_fmt, we should
+ * do something for a generic case as well.
* - decoding: set by lavc.
*/
enum PixelFormat pix_fmt;
@@ -470,10 +583,14 @@ typedef struct AVCodecContext {
* before
* - encoding: unused
* - decoding: set by user.
+ * @param height the height of the slice
+ * @param y the y position of the slice
+ * @param type 1->top field, 2->bottom field, 3->frame
+ * @param offset offset into the AVFrame.data from which the slice should be read
*/
void (*draw_horiz_band)(struct AVCodecContext *s,
- uint8_t **src_ptr, int linesize,
- int y, int width, int height);
+ const AVFrame *src, int offset[4],
+ int y, int type, int height);
/* audio only */
int sample_rate; ///< samples per sec
@@ -599,7 +716,7 @@ typedef struct AVCodecContext {
/**
* fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
* this is used to workaround some encoder bugs
- * - encoding: unused
+ * - encoding: set by user, if not then the default based on codec_id will be used
* - decoding: set by user, will be converted to upper case by lavc during init
*/
unsigned int codec_tag;
@@ -615,7 +732,7 @@ typedef struct AVCodecContext {
#define FF_BUG_XVID_ILACE 4
#define FF_BUG_UMP4 8
#define FF_BUG_NO_PADDING 16
-#define FF_BUG_AC_VLC 32
+#define FF_BUG_AC_VLC 0 ///< will be removed, libavcodec can now handle these non compliant files by default
#define FF_BUG_QPEL_CHROMA 64
#define FF_BUG_STD_QPEL 128
#define FF_BUG_QPEL_CHROMA2 256
@@ -668,6 +785,7 @@ typedef struct AVCodecContext {
/**
* called at the beginning of each frame to get a buffer for it.
* if pic.reference is set then the frame will be read later by lavc
+ * width and height should be rounded up to the next multiple of 16
* - encoding: unused
* - decoding: set by lavc, user can override
*/
@@ -856,6 +974,7 @@ typedef struct AVCodecContext {
#define FF_IDCT_ARM 7
#define FF_IDCT_ALTIVEC 8
#define FF_IDCT_SH4 9
+#define FF_IDCT_SIMPLEARM 10
/**
* slice count.
@@ -916,11 +1035,11 @@ typedef struct AVCodecContext {
#define FF_PRED_MEDIAN 2
/**
- * aspect ratio (0 if unknown).
+ * sample aspect ratio (0 if unknown).
* - encoding: set by user.
* - decoding: set by lavc.
*/
- float aspect_ratio;
+ AVRational sample_aspect_ratio;
/**
* the picture in the bitstream.
@@ -947,6 +1066,7 @@ typedef struct AVCodecContext {
#define FF_DEBUG_PTS 0x00000200
#define FF_DEBUG_ER 0x00000400
#define FF_DEBUG_MMCO 0x00000800
+#define FF_DEBUG_BUGS 0x00001000
/**
* error.
@@ -1119,8 +1239,13 @@ typedef struct AVCodecContext {
* Dont touch, used by lavc default_get_buffer()
*/
void *internal_buffer;
-
-#define FF_QUALITY_SCALE 256
+
+#define FF_LAMBDA_SHIFT 7
+#define FF_LAMBDA_SCALE (1<<FF_LAMBDA_SHIFT)
+#define FF_QP2LAMBDA 118 ///< factor to convert from H.263 QP to lambda
+#define FF_LAMBDA_MAX (256*128-1)
+
+#define FF_QUALITY_SCALE FF_LAMBDA_SCALE //FIXME maybe remove
/**
* global quality for codecs which cannot change it per frame.
* this should be proportional to MPEG1/2/4 qscale.
@@ -1144,6 +1269,78 @@ typedef struct AVCodecContext {
* - decoding: unused
*/
int context_model;
+
+ /**
+ * slice flags
+ * - encoding: unused
+ * - decoding: set by user.
+ */
+ int slice_flags;
+#define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display
+#define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics)
+#define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
+
+ /**
+ * XVideo Motion Acceleration
+ * - encoding: forbidden
+ * - decoding: set by decoder
+ */
+ int xvmc_acceleration;
+
+ /**
+ * macroblock decision mode
+ * - encoding: set by user.
+ * - decoding: unused
+ */
+ int mb_decision;
+#define FF_MB_DECISION_SIMPLE 0 ///< uses mb_cmp
+#define FF_MB_DECISION_BITS 1 ///< chooses the one which needs the fewest bits
+#define FF_MB_DECISION_RD 2 ///< rate distoration
+
+ /**
+ * custom intra quantization matrix
+ * - encoding: set by user, can be NULL
+ * - decoding: set by lavc
+ */
+ uint16_t *intra_matrix;
+
+ /**
+ * custom inter quantization matrix
+ * - encoding: set by user, can be NULL
+ * - decoding: set by lavc
+ */
+ uint16_t *inter_matrix;
+
+ /**
+ * fourcc from the AVI stream header (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
+ * this is used to workaround some encoder bugs
+ * - encoding: unused
+ * - decoding: set by user, will be converted to upper case by lavc during init
+ */
+ unsigned int stream_codec_tag;
+
+ /**
+ * scene change detection threshold.
+ * 0 is default, larger means fewer detected scene changes
+ * - encoding: set by user.
+ * - decoding: unused
+ */
+ int scenechange_threshold;
+
+ /**
+ * minimum lagrange multipler
+ * - encoding: set by user.
+ * - decoding: unused
+ */
+ int lmin;
+
+ /**
+ * maximum lagrange multipler
+ * - encoding: set by user.
+ * - decoding: unused
+ */
+ int lmax;
+
} AVCodecContext;
@@ -1207,6 +1404,7 @@ typedef struct AVCodec {
int capabilities;
const AVOption *options;
struct AVCodec *next;
+ void (*flush)(AVCodecContext *);
} AVCodec;
/**
@@ -1218,13 +1416,35 @@ typedef struct AVPicture {
int linesize[4]; ///< number of bytes per line
} AVPicture;
+/**
+ * AVPaletteControl
+ * This structure defines a method for communicating palette changes
+ * between and demuxer and a decoder.
+ */
+typedef struct AVPaletteControl {
+
+ /* demuxer sets this to 1 to indicate the palette has changed;
+ * decoder resets to 0 */
+ int palette_changed;
+
+ /* 256 3-byte RGB palette entries; the components should be
+ * formatted in the buffer as "RGBRGB..." and should be scaled to
+ * 8 bits if they originally represented 6-bit VGA palette
+ * components */
+ unsigned char palette[256 * 3];
+
+} AVPaletteControl;
+
extern AVCodec ac3_encoder;
extern AVCodec mp2_encoder;
extern AVCodec mp3lame_encoder;
extern AVCodec oggvorbis_encoder;
+extern AVCodec faac_encoder;
extern AVCodec mpeg1video_encoder;
+extern AVCodec mpeg2video_encoder;
extern AVCodec h263_encoder;
extern AVCodec h263p_encoder;
+extern AVCodec flv_encoder;
extern AVCodec rv10_encoder;
extern AVCodec mjpeg_encoder;
extern AVCodec ljpeg_encoder;
@@ -1237,7 +1457,10 @@ extern AVCodec wmv2_encoder;
extern AVCodec huffyuv_encoder;
extern AVCodec h264_encoder;
extern AVCodec asv1_encoder;
+extern AVCodec asv2_encoder;
+extern AVCodec vcr1_encoder;
extern AVCodec ffv1_encoder;
+extern AVCodec mdec_encoder;
extern AVCodec h263_decoder;
extern AVCodec mpeg4_decoder;
@@ -1246,17 +1469,20 @@ extern AVCodec msmpeg4v2_decoder;
extern AVCodec msmpeg4v3_decoder;
extern AVCodec wmv1_decoder;
extern AVCodec wmv2_decoder;
-extern AVCodec mpeg_decoder;
+extern AVCodec mpeg1video_decoder;
+extern AVCodec mpeg2video_decoder;
+extern AVCodec mpeg_xvmc_decoder;
extern AVCodec h263i_decoder;
+extern AVCodec flv_decoder;
extern AVCodec rv10_decoder;
extern AVCodec svq1_decoder;
extern AVCodec svq3_decoder;
extern AVCodec dvvideo_decoder;
-extern AVCodec dvaudio_decoder;
extern AVCodec wmav1_decoder;
extern AVCodec wmav2_decoder;
extern AVCodec mjpeg_decoder;
extern AVCodec mjpegb_decoder;
+extern AVCodec sp5x_decoder;
extern AVCodec mp2_decoder;
extern AVCodec mp3_decoder;
extern AVCodec mace3_decoder;
@@ -1267,15 +1493,34 @@ extern AVCodec cyuv_decoder;
extern AVCodec h264_decoder;
extern AVCodec indeo3_decoder;
extern AVCodec vp3_decoder;
+extern AVCodec theora_decoder;
extern AVCodec amr_nb_decoder;
extern AVCodec amr_nb_encoder;
+extern AVCodec amr_wb_encoder;
+extern AVCodec amr_wb_decoder;
extern AVCodec aac_decoder;
extern AVCodec mpeg4aac_decoder;
extern AVCodec asv1_decoder;
+extern AVCodec asv2_decoder;
+extern AVCodec vcr1_decoder;
+extern AVCodec cljr_decoder;
extern AVCodec ffv1_decoder;
extern AVCodec fourxm_decoder;
+extern AVCodec mdec_decoder;
+extern AVCodec roq_decoder;
+extern AVCodec interplay_video_decoder;
+extern AVCodec xan_wc3_decoder;
+extern AVCodec rpza_decoder;
+extern AVCodec cinepak_decoder;
+extern AVCodec msrle_decoder;
+extern AVCodec msvideo1_decoder;
+extern AVCodec vqa_decoder;
+extern AVCodec idcin_decoder;
extern AVCodec ra_144_decoder;
extern AVCodec ra_288_decoder;
+extern AVCodec roq_dpcm_decoder;
+extern AVCodec interplay_dpcm_decoder;
+extern AVCodec xan_dpcm_decoder;
/* pcm codecs */
#define PCM_CODEC(id, name) \
@@ -1295,8 +1540,13 @@ 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_IMA_DK3, adpcm_ima_dk3);
+PCM_CODEC(CODEC_ID_ADPCM_IMA_DK4, adpcm_ima_dk4);
+PCM_CODEC(CODEC_ID_ADPCM_IMA_WS, adpcm_ima_ws);
PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
PCM_CODEC(CODEC_ID_ADPCM_4XM, adpcm_4xm);
+PCM_CODEC(CODEC_ID_ADPCM_XA, adpcm_xa);
+PCM_CODEC(CODEC_ID_ADPCM_ADX, adpcm_adx);
#undef PCM_CODEC
@@ -1333,13 +1583,27 @@ ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
int leftBand, int rightBand);
void img_resample(ImgReSampleContext *s,
- AVPicture *output, AVPicture *input);
+ AVPicture *output, const AVPicture *input);
void img_resample_close(ImgReSampleContext *s);
+/**
+ * Allocate memory for a picture. Call avpicture_free to free it.
+ *
+ * @param picture the picture to be filled in.
+ * @param pix_fmt the format of the picture.
+ * @param width the width of the picture.
+ * @param height the height of the picture.
+ * @return 0 if successful, -1 if not.
+ */
+int avpicture_alloc(AVPicture *picture, int pix_fmt, int width, int height);
+
+/* Free a picture previously allocated by avpicture_alloc. */
+void avpicture_free(AVPicture *picture);
+
int avpicture_fill(AVPicture *picture, uint8_t *ptr,
int pix_fmt, int width, int height);
-int avpicture_layout(AVPicture* src, int pix_fmt, int width, int height,
+int avpicture_layout(const AVPicture* src, int pix_fmt, int width, int height,
unsigned char *dest, int dest_size);
int avpicture_get_size(int pix_fmt, int width, int height);
void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift);
@@ -1360,15 +1624,16 @@ int avcodec_find_best_pix_fmt(int pix_fmt_mask, int src_pix_fmt,
#define FF_ALPHA_TRANSP 0x0001 /* image has some totally transparent pixels */
#define FF_ALPHA_SEMI_TRANSP 0x0002 /* image has some transparent pixels */
-int img_get_alpha_info(AVPicture *src, int pix_fmt, int width, int height);
+int img_get_alpha_info(const AVPicture *src,
+ int pix_fmt, int width, int height);
/* convert among pixel formats */
int img_convert(AVPicture *dst, int dst_pix_fmt,
- AVPicture *src, int pix_fmt,
+ const AVPicture *src, int pix_fmt,
int width, int height);
/* deinterlace a picture */
-int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
+int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
int pix_fmt, int width, int height);
/* external high level API */
@@ -1396,7 +1661,12 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
void avcodec_default_free_buffers(AVCodecContext *s);
+/**
+ * opens / inits the AVCodecContext.
+ * not thread save!
+ */
int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
+
int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
int *frame_size_ptr,
uint8_t *buf, int buf_size);
@@ -1530,6 +1800,9 @@ void av_free_static(void);
void *__av_mallocz_static(void** location, unsigned int size);
#define av_mallocz_static(p, s) __av_mallocz_static((void **)(p), s)
+/* add by bero : in adx.c */
+int is_adx(const unsigned char *buf,size_t bufsize);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/libffmpeg/libavcodec/cabac.c b/src/libffmpeg/libavcodec/cabac.c
new file mode 100644
index 000000000..27e63045b
--- /dev/null
+++ b/src/libffmpeg/libavcodec/cabac.c
@@ -0,0 +1,206 @@
+/*
+ * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder
+ * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * 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 cabac.c
+ * Context Adaptive Binary Arithmetic Coder.
+ */
+
+#include <string.h>
+
+#include "common.h"
+#include "cabac.h"
+
+const uint8_t ff_h264_lps_range[64][4]= {
+{128,176,208,240}, {128,167,197,227}, {128,158,187,216}, {123,150,178,205},
+{116,142,169,195}, {111,135,160,185}, {105,128,152,175}, {100,122,144,166},
+{ 95,116,137,158}, { 90,110,130,150}, { 85,104,123,142}, { 81, 99,117,135},
+{ 77, 94,111,128}, { 73, 89,105,122}, { 69, 85,100,116}, { 66, 80, 95,110},
+{ 62, 76, 90,104}, { 59, 72, 86, 99}, { 56, 69, 81, 94}, { 53, 65, 77, 89},
+{ 51, 62, 73, 85}, { 48, 59, 69, 80}, { 46, 56, 66, 76}, { 43, 53, 63, 72},
+{ 41, 50, 59, 69}, { 39, 48, 56, 65}, { 37, 45, 54, 62}, { 35, 43, 51, 59},
+{ 33, 41, 48, 56}, { 32, 39, 46, 53}, { 30, 37, 43, 50}, { 29, 35, 41, 48},
+{ 27, 33, 39, 45}, { 26, 31, 37, 43}, { 24, 30, 35, 41}, { 23, 28, 33, 39},
+{ 22, 27, 32, 37}, { 21, 26, 30, 35}, { 20, 24, 29, 33}, { 19, 23, 27, 31},
+{ 18, 22, 26, 30}, { 17, 21, 25, 28}, { 16, 20, 23, 27}, { 15, 19, 22, 25},
+{ 14, 18, 21, 24}, { 14, 17, 20, 23}, { 13, 16, 19, 22}, { 12, 15, 18, 21},
+{ 12, 14, 17, 20}, { 11, 14, 16, 19}, { 11, 13, 15, 18}, { 10, 12, 15, 17},
+{ 10, 12, 14, 16}, { 9, 11, 13, 15}, { 9, 11, 12, 14}, { 8, 10, 12, 14},
+{ 8, 9, 11, 13}, { 7, 9, 11, 12}, { 7, 9, 10, 12}, { 7, 8, 10, 11},
+{ 6, 8, 9, 11}, { 6, 7, 9, 10}, { 6, 7, 8, 9}, { 2, 2, 2, 2},
+};
+
+const uint8_t ff_h264_mps_state[64]= {
+ 1, 2, 3, 4, 5, 6, 7, 8,
+ 9,10,11,12,13,14,15,16,
+ 17,18,19,20,21,22,23,24,
+ 25,26,27,28,29,30,31,32,
+ 33,34,35,36,37,38,39,40,
+ 41,42,43,44,45,46,47,48,
+ 49,50,51,52,53,54,55,56,
+ 57,58,59,60,61,62,62,63,
+};
+
+const uint8_t ff_h264_lps_state[64]= {
+ 0, 0, 1, 2, 2, 4, 4, 5,
+ 6, 7, 8, 9, 9,11,11,12,
+ 13,13,15,15,16,16,18,18,
+ 19,19,21,21,22,22,23,24,
+ 24,25,26,26,27,27,28,29,
+ 29,30,30,30,31,32,32,33,
+ 33,33,34,34,35,35,35,36,
+ 36,36,37,37,37,38,38,63,
+};
+
+/**
+ *
+ * @param buf_size size of buf in bits
+ */
+void ff_init_cabac_encoder(CABACContext *c, uint8_t *buf, int buf_size){
+ init_put_bits(&c->pb, buf, buf_size);
+
+ c->low= 0;
+ c->range= 0x1FE;
+ c->outstanding_count= 0;
+#ifdef STRICT_LIMITS
+ c->sym_count =0;
+#endif
+
+ c->pb.bit_left++; //avoids firstBitFlag
+}
+
+/**
+ *
+ * @param buf_size size of buf in bits
+ */
+void ff_init_cabac_decoder(CABACContext *c, uint8_t *buf, int buf_size){
+ c->bytestream_start=
+ c->bytestream= buf;
+
+ c->low= *c->bytestream++;
+ c->low= (c->low<<9) + ((*c->bytestream++)<<1);
+ c->range= 0x1FE00;
+ c->bits_left= 7;
+}
+
+void ff_init_cabac_states(CABACContext *c, uint8_t const (*lps_range)[4],
+ uint8_t const *mps_state, uint8_t const *lps_state, int state_count){
+ int i, j;
+
+ for(i=0; i<state_count; i++){
+ for(j=0; j<4; j++){ //FIXME check if this is worth the 1 shift we save
+ c->lps_range[2*i+0][j]=
+ c->lps_range[2*i+1][j]= lps_range[i][j];
+ }
+
+ c->mps_state[2*i+0]= 2*mps_state[i];
+ c->mps_state[2*i+1]= 2*mps_state[i]+1;
+
+ if(lps_state[i]){
+ c->lps_state[2*i+0]= 2*lps_state[i];
+ c->lps_state[2*i+1]= 2*lps_state[i]+1;
+ }else{
+ c->lps_state[2*i+0]= 1;
+ c->lps_state[2*i+1]= 0;
+ }
+ }
+}
+
+#if 0 //selftest
+#define SIZE 10240
+int main(){
+ CABACContext c;
+ uint8_t b[9*SIZE];
+ uint8_t r[9*SIZE];
+ int i;
+ uint8_t state[10]= {0};
+
+ ff_init_cabac_encoder(&c, b, SIZE);
+ ff_init_cabac_states(&c, ff_h264_lps_range, ff_h264_mps_state, ff_h264_lps_state, 64);
+
+ for(i=0; i<SIZE; i++){
+ r[i]= random()%7;
+ }
+
+ for(i=0; i<SIZE; i++){
+START_TIMER
+ put_cabac_bypass(&c, r[i]&1);
+STOP_TIMER("put_cabac_bypass")
+ }
+
+ for(i=0; i<SIZE; i++){
+START_TIMER
+ put_cabac(&c, state, r[i]&1);
+STOP_TIMER("put_cabac")
+ }
+
+ for(i=0; i<SIZE; i++){
+START_TIMER
+ put_cabac_u(&c, state, r[i], 6, 3, i&1);
+STOP_TIMER("put_cabac_u")
+ }
+
+ for(i=0; i<SIZE; i++){
+START_TIMER
+ put_cabac_ueg(&c, state, r[i], 3, 0, 1, 2);
+STOP_TIMER("put_cabac_ueg")
+ }
+
+ put_cabac_terminate(&c, 1);
+
+ ff_init_cabac_decoder(&c, b, SIZE);
+
+ memset(state, 0, sizeof(state));
+
+ for(i=0; i<SIZE; i++){
+START_TIMER
+ if( (r[i]&1) != get_cabac_bypass(&c) )
+ printf("CABAC bypass failure at %d\n", i);
+STOP_TIMER("get_cabac_bypass")
+ }
+
+ for(i=0; i<SIZE; i++){
+START_TIMER
+ if( (r[i]&1) != get_cabac(&c, state) )
+ printf("CABAC failure at %d\n", i);
+STOP_TIMER("get_cabac")
+ }
+
+ for(i=0; i<SIZE; i++){
+START_TIMER
+ if( r[i] != get_cabac_u(&c, state, (i&1) ? 6 : 7, 3, i&1) )
+ printf("CABAC unary (truncated) binarization failure at %d\n", i);
+STOP_TIMER("get_cabac_u")
+ }
+
+ for(i=0; i<SIZE; i++){
+START_TIMER
+ if( r[i] != get_cabac_ueg(&c, state, 3, 0, 1, 2))
+ printf("CABAC unary (truncated) binarization failure at %d\n", i);
+STOP_TIMER("get_cabac_ueg")
+ }
+
+ if(!get_cabac_terminate(&c))
+ printf("where's the Terminator?\n");
+
+ return 0;
+}
+
+#endif
diff --git a/src/libffmpeg/libavcodec/cabac.h b/src/libffmpeg/libavcodec/cabac.h
new file mode 100644
index 000000000..a49e15631
--- /dev/null
+++ b/src/libffmpeg/libavcodec/cabac.h
@@ -0,0 +1,381 @@
+/*
+ * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder
+ * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * 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 cabac.h
+ * Context Adaptive Binary Arithmetic Coder.
+ */
+
+
+#undef NDEBUG
+#include <assert.h>
+
+typedef struct CABACContext{
+ int low;
+ int range;
+ int outstanding_count;
+#ifdef STRICT_LIMITS
+ int symCount;
+#endif
+ uint8_t lps_range[2*64][4]; ///< rangeTabLPS
+ uint8_t lps_state[2*64]; ///< transIdxLPS
+ uint8_t mps_state[2*64]; ///< transIdxMPS
+ uint8_t *bytestream_start;
+ uint8_t *bytestream;
+ int bits_left; ///<
+ PutBitContext pb;
+}CABACContext;
+
+extern const uint8_t ff_h264_lps_range[64][4];
+extern const uint8_t ff_h264_mps_state[64];
+extern const uint8_t ff_h264_lps_state[64];
+
+void ff_init_cabac_encoder(CABACContext *c, uint8_t *buf, int buf_size);
+void ff_init_cabac_decoder(CABACContext *c, uint8_t *buf, int buf_size);
+void ff_init_cabac_states(CABACContext *c, uint8_t const (*lps_range)[4],
+ uint8_t const *mps_state, uint8_t const *lps_state, int state_count);
+
+
+static inline void put_cabac_bit(CABACContext *c, int b){
+ put_bits(&c->pb, 1, b);
+ for(;c->outstanding_count; c->outstanding_count--){
+ put_bits(&c->pb, 1, 1-b);
+ }
+}
+
+static inline void renorm_cabac_encoder(CABACContext *c){
+ while(c->range < 0x100){
+ //FIXME optimize
+ if(c->low<0x100){
+ put_cabac_bit(c, 0);
+ }else if(c->low<0x200){
+ c->outstanding_count++;
+ c->low -= 0x100;
+ }else{
+ put_cabac_bit(c, 1);
+ c->low -= 0x200;
+ }
+
+ c->range+= c->range;
+ c->low += c->low;
+ }
+}
+
+static inline void put_cabac(CABACContext *c, uint8_t * const state, int bit){
+ int RangeLPS= c->lps_range[*state][((c->range)>>6)&3];
+
+ if(bit == ((*state)&1)){
+ c->range -= RangeLPS;
+ *state= c->mps_state[*state];
+ }else{
+ c->low += c->range - RangeLPS;
+ c->range = RangeLPS;
+ *state= c->lps_state[*state];
+ }
+
+ renorm_cabac_encoder(c);
+
+#ifdef STRICT_LIMITS
+ c->symCount++;
+#endif
+}
+
+static inline void put_cabac_static(CABACContext *c, int RangeLPS, int bit){
+ assert(c->range > RangeLPS);
+
+ if(!bit){
+ c->range -= RangeLPS;
+ }else{
+ c->low += c->range - RangeLPS;
+ c->range = RangeLPS;
+ }
+
+ renorm_cabac_encoder(c);
+
+#ifdef STRICT_LIMITS
+ c->symCount++;
+#endif
+}
+
+/**
+ * @param bit 0 -> write zero bit, !=0 write one bit
+ */
+static inline void put_cabac_bypass(CABACContext *c, int bit){
+ c->low += c->low;
+
+ if(bit){
+ c->low += c->range;
+ }
+//FIXME optimize
+ if(c->low<0x200){
+ put_cabac_bit(c, 0);
+ }else if(c->low<0x400){
+ c->outstanding_count++;
+ c->low -= 0x200;
+ }else{
+ put_cabac_bit(c, 1);
+ c->low -= 0x400;
+ }
+
+#ifdef STRICT_LIMITS
+ c->symCount++;
+#endif
+}
+
+/**
+ *
+ * @return the number of bytes written
+ */
+static inline int put_cabac_terminate(CABACContext *c, int bit){
+ c->range -= 2;
+
+ if(!bit){
+ renorm_cabac_encoder(c);
+ }else{
+ c->low += c->range;
+ c->range= 2;
+
+ renorm_cabac_encoder(c);
+
+ assert(c->low <= 0x1FF);
+ put_cabac_bit(c, c->low>>9);
+ put_bits(&c->pb, 2, ((c->low>>7)&3)|1);
+
+ flush_put_bits(&c->pb); //FIXME FIXME FIXME XXX wrong
+ }
+
+#ifdef STRICT_LIMITS
+ c->symCount++;
+#endif
+
+ return (get_bit_count(&c->pb)+7)>>3;
+}
+
+/**
+ * put (truncated) unary binarization.
+ */
+static inline void put_cabac_u(CABACContext *c, uint8_t * state, int v, int max, int max_index, int truncated){
+ int i;
+
+ assert(v <= max);
+
+#if 1
+ for(i=0; i<v; i++){
+ put_cabac(c, state, 1);
+ if(i < max_index) state++;
+ }
+ if(truncated==0 || v<max)
+ put_cabac(c, state, 0);
+#else
+ if(v <= max_index){
+ for(i=0; i<v; i++){
+ put_cabac(c, state+i, 1);
+ }
+ if(truncated==0 || v<max)
+ put_cabac(c, state+i, 0);
+ }else{
+ for(i=0; i<=max_index; i++){
+ put_cabac(c, state+i, 1);
+ }
+ for(; i<v; i++){
+ put_cabac(c, state+max_index, 1);
+ }
+ if(truncated==0 || v<max)
+ put_cabac(c, state+max_index, 0);
+ }
+#endif
+}
+
+/**
+ * put unary exp golomb k-th order binarization.
+ */
+static inline void put_cabac_ueg(CABACContext *c, uint8_t * state, int v, int max, int is_signed, int k, int max_index){
+ int i;
+
+ if(v==0)
+ put_cabac(c, state, 0);
+ else{
+ const int sign= v < 0;
+
+ if(is_signed) v= ABS(v);
+
+ if(v<max){
+ for(i=0; i<v; i++){
+ put_cabac(c, state, 1);
+ if(i < max_index) state++;
+ }
+
+ put_cabac(c, state, 0);
+ }else{
+ int m= 1<<k;
+
+ for(i=0; i<max; i++){
+ put_cabac(c, state, 1);
+ if(i < max_index) state++;
+ }
+
+ v -= max;
+ while(v >= m){ //FIXME optimize
+ put_cabac_bypass(c, 1);
+ v-= m;
+ m+= m;
+ }
+ put_cabac_bypass(c, 0);
+ while(m>>=1){
+ put_cabac_bypass(c, v&m);
+ }
+ }
+
+ if(is_signed)
+ put_cabac_bypass(c, sign);
+ }
+}
+
+static inline void renorm_cabac_decoder(CABACContext *c){
+ while(c->range < 0x10000){
+ c->range+= c->range;
+ c->low+= c->low;
+ if(--c->bits_left == 0){
+ c->low+= *c->bytestream++;
+ c->bits_left= 8;
+ }
+ }
+}
+
+static inline int get_cabac(CABACContext *c, uint8_t * const state){
+ int RangeLPS= c->lps_range[*state][((c->range)>>14)&3]<<8;
+ int bit;
+
+ c->range -= RangeLPS;
+ if(c->low < c->range){
+ bit= (*state)&1;
+ *state= c->mps_state[*state];
+ }else{
+ bit= ((*state)&1)^1;
+ c->low -= c->range;
+ c->range = RangeLPS;
+ *state= c->lps_state[*state];
+ }
+ renorm_cabac_decoder(c);
+
+ return bit;
+}
+
+static inline int get_cabac_static(CABACContext *c, int RangeLPS){
+ int bit;
+
+ c->range -= RangeLPS;
+ if(c->low < c->range){
+ bit= 0;
+ }else{
+ bit= 1;
+ c->low -= c->range;
+ c->range = RangeLPS;
+ }
+ renorm_cabac_decoder(c);
+
+ return bit;
+}
+
+static inline int get_cabac_bypass(CABACContext *c){
+ c->low += c->low;
+
+ if(--c->bits_left == 0){
+ c->low+= *c->bytestream++;
+ c->bits_left= 8;
+ }
+
+ if(c->low < c->range){
+ return 0;
+ }else{
+ c->low -= c->range;
+ return 1;
+ }
+}
+
+/**
+ *
+ * @return the number of bytes read or 0 if no end
+ */
+static inline int get_cabac_terminate(CABACContext *c){
+ c->range -= 2<<8;
+ if(c->low < c->range){
+ renorm_cabac_decoder(c);
+ return 0;
+ }else{
+ return c->bytestream - c->bytestream_start;
+ }
+}
+
+/**
+ * get (truncated) unnary binarization.
+ */
+static inline int get_cabac_u(CABACContext *c, uint8_t * state, int max, int max_index, int truncated){
+ int i;
+
+ for(i=0; i<max; i++){
+ if(get_cabac(c, state)==0)
+ return i;
+
+ if(i< max_index) state++;
+ }
+
+ return truncated ? max : -1;
+}
+
+/**
+ * get unary exp golomb k-th order binarization.
+ */
+static inline int get_cabac_ueg(CABACContext *c, uint8_t * state, int max, int is_signed, int k, int max_index){
+ int i, v;
+ int m= 1<<k;
+
+ if(get_cabac(c, state)==0)
+ return 0;
+
+ if(0 < max_index) state++;
+
+ for(i=1; i<max; i++){
+ if(get_cabac(c, state)==0){
+ if(is_signed && get_cabac_bypass(c)){
+ return -i;
+ }else
+ return i;
+ }
+
+ if(i < max_index) state++;
+ }
+
+ while(get_cabac_bypass(c)){
+ i+= m;
+ m+= m;
+ }
+
+ v=0;
+ while(m>>=1){
+ v+= v + get_cabac_bypass(c);
+ }
+ i += v;
+
+ if(is_signed && get_cabac_bypass(c)){
+ return -i;
+ }else
+ return i;
+}
diff --git a/src/libffmpeg/libavcodec/cinepak.c b/src/libffmpeg/libavcodec/cinepak.c
new file mode 100644
index 000000000..af168d07b
--- /dev/null
+++ b/src/libffmpeg/libavcodec/cinepak.c
@@ -0,0 +1,460 @@
+/*
+ * Cinepak Video Decoder
+ * 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
+ *
+ */
+
+/**
+ * @file cinepak.c
+ * Cinepak video decoder
+ * by Ewald Snel <ewald@rambo.its.tudelft.nl>
+ * For more information on the Cinepak algorithm, visit:
+ * http://www.csse.monash.edu.au/~timf/
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "common.h"
+#include "avcodec.h"
+#include "dsputil.h"
+
+#define PALETTE_COUNT 256
+
+#define BE_16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1])
+#define BE_32(x) ((((uint8_t*)(x))[0] << 24) | \
+ (((uint8_t*)(x))[1] << 16) | \
+ (((uint8_t*)(x))[2] << 8) | \
+ ((uint8_t*)(x))[3])
+
+typedef struct {
+ uint8_t y0, y1, y2, y3;
+ uint8_t u, v;
+} cvid_codebook_t;
+
+#define MAX_STRIPS 32
+
+typedef struct {
+ uint16_t id;
+ uint16_t x1, y1;
+ uint16_t x2, y2;
+ cvid_codebook_t v4_codebook[256];
+ cvid_codebook_t v1_codebook[256];
+} cvid_strip_t;
+
+typedef struct CinepakContext {
+
+ AVCodecContext *avctx;
+ DSPContext dsp;
+ AVFrame frame;
+ AVFrame prev_frame;
+
+ unsigned char *data;
+ int size;
+
+ int width, height;
+
+ unsigned char palette[PALETTE_COUNT * 4];
+ int palette_video;
+ cvid_strip_t strips[MAX_STRIPS];
+
+} CinepakContext;
+
+static void cinepak_decode_codebook (cvid_codebook_t *codebook,
+ int chunk_id, int size, uint8_t *data)
+{
+ uint8_t *eod = (data + size);
+ uint32_t flag, mask;
+ int i, n;
+
+ /* check if this chunk contains 4- or 6-element vectors */
+ n = (chunk_id & 0x0400) ? 4 : 6;
+ flag = 0;
+ mask = 0;
+
+ for (i=0; i < 256; i++) {
+ if ((chunk_id & 0x0100) && !(mask >>= 1)) {
+ if ((data + 4) > eod)
+ break;
+
+ flag = BE_32 (data);
+ data += 4;
+ mask = 0x80000000;
+ }
+
+ if (!(chunk_id & 0x0100) || (flag & mask)) {
+ if ((data + n) > eod)
+ break;
+
+ if (n == 6) {
+ codebook[i].y0 = *data++;
+ codebook[i].y1 = *data++;
+ codebook[i].y2 = *data++;
+ codebook[i].y3 = *data++;
+ codebook[i].u = 128 + *data++;
+ codebook[i].v = 128 + *data++;
+ } else {
+ /* this codebook type indicates either greyscale or
+ * palettized video; if palettized, U & V components will
+ * not be used so it is safe to set them to 128 for the
+ * benefit of greyscale rendering in YUV420P */
+ codebook[i].y0 = *data++;
+ codebook[i].y1 = *data++;
+ codebook[i].y2 = *data++;
+ codebook[i].y3 = *data++;
+ codebook[i].u = 128;
+ codebook[i].v = 128;
+ }
+ }
+ }
+}
+
+static int cinepak_decode_vectors (CinepakContext *s, cvid_strip_t *strip,
+ int chunk_id, int size, uint8_t *data)
+{
+ uint8_t *eod = (data + size);
+ uint32_t flag, mask;
+ cvid_codebook_t *codebook;
+ unsigned int i, j, x, y;
+ uint32_t iy[4];
+ uint32_t iu[2];
+ uint32_t iv[2];
+
+ flag = 0;
+ mask = 0;
+
+ for (y=strip->y1; y < strip->y2; y+=4) {
+
+ iy[0] = strip->x1 + (y * s->frame.linesize[0]);
+ iy[1] = iy[0] + s->frame.linesize[0];
+ iy[2] = iy[1] + s->frame.linesize[0];
+ iy[3] = iy[2] + s->frame.linesize[0];
+ iu[0] = (strip->x1/2) + ((y/2) * s->frame.linesize[1]);
+ iu[1] = iu[0] + s->frame.linesize[1];
+ iv[0] = (strip->x1/2) + ((y/2) * s->frame.linesize[2]);
+ iv[1] = iv[0] + s->frame.linesize[2];
+
+ for (x=strip->x1; x < strip->x2; x+=4) {
+ if ((chunk_id & 0x0100) && !(mask >>= 1)) {
+ if ((data + 4) > eod)
+ return -1;
+
+ flag = BE_32 (data);
+ data += 4;
+ mask = 0x80000000;
+ }
+
+ if (!(chunk_id & 0x0100) || (flag & mask)) {
+ if (!(chunk_id & 0x0200) && !(mask >>= 1)) {
+ if ((data + 4) > eod)
+ return -1;
+
+ flag = BE_32 (data);
+ data += 4;
+ mask = 0x80000000;
+ }
+
+ if ((chunk_id & 0x0200) || (~flag & mask)) {
+ if (data >= eod)
+ return -1;
+
+ codebook = &strip->v1_codebook[*data++];
+ s->frame.data[0][iy[0] + 0] = codebook->y0;
+ s->frame.data[0][iy[0] + 1] = codebook->y0;
+ s->frame.data[0][iy[1] + 0] = codebook->y0;
+ s->frame.data[0][iy[1] + 1] = codebook->y0;
+ if (!s->palette_video) {
+ s->frame.data[1][iu[0]] = codebook->u;
+ s->frame.data[2][iv[0]] = codebook->v;
+ }
+
+ s->frame.data[0][iy[0] + 2] = codebook->y0;
+ s->frame.data[0][iy[0] + 3] = codebook->y0;
+ s->frame.data[0][iy[1] + 2] = codebook->y0;
+ s->frame.data[0][iy[1] + 3] = codebook->y0;
+ if (!s->palette_video) {
+ s->frame.data[1][iu[0] + 1] = codebook->u;
+ s->frame.data[2][iv[0] + 1] = codebook->v;
+ }
+
+ s->frame.data[0][iy[2] + 0] = codebook->y0;
+ s->frame.data[0][iy[2] + 1] = codebook->y0;
+ s->frame.data[0][iy[3] + 0] = codebook->y0;
+ s->frame.data[0][iy[3] + 1] = codebook->y0;
+ if (!s->palette_video) {
+ s->frame.data[1][iu[1]] = codebook->u;
+ s->frame.data[2][iv[1]] = codebook->v;
+ }
+
+ s->frame.data[0][iy[2] + 2] = codebook->y0;
+ s->frame.data[0][iy[2] + 3] = codebook->y0;
+ s->frame.data[0][iy[3] + 2] = codebook->y0;
+ s->frame.data[0][iy[3] + 3] = codebook->y0;
+ if (!s->palette_video) {
+ s->frame.data[1][iu[1] + 1] = codebook->u;
+ s->frame.data[2][iv[1] + 1] = codebook->v;
+ }
+
+ } else if (flag & mask) {
+ if ((data + 4) > eod)
+ return -1;
+
+ codebook = &strip->v4_codebook[*data++];
+ s->frame.data[0][iy[0] + 0] = codebook->y0;
+ s->frame.data[0][iy[0] + 1] = codebook->y1;
+ s->frame.data[0][iy[1] + 0] = codebook->y2;
+ s->frame.data[0][iy[1] + 1] = codebook->y3;
+ if (!s->palette_video) {
+ s->frame.data[1][iu[0]] = codebook->u;
+ s->frame.data[2][iv[0]] = codebook->v;
+ }
+
+ codebook = &strip->v4_codebook[*data++];
+ s->frame.data[0][iy[0] + 2] = codebook->y0;
+ s->frame.data[0][iy[0] + 3] = codebook->y1;
+ s->frame.data[0][iy[1] + 2] = codebook->y2;
+ s->frame.data[0][iy[1] + 3] = codebook->y3;
+ if (!s->palette_video) {
+ s->frame.data[1][iu[0] + 1] = codebook->u;
+ s->frame.data[2][iv[0] + 1] = codebook->v;
+ }
+
+ codebook = &strip->v4_codebook[*data++];
+ s->frame.data[0][iy[2] + 0] = codebook->y0;
+ s->frame.data[0][iy[2] + 1] = codebook->y1;
+ s->frame.data[0][iy[3] + 0] = codebook->y2;
+ s->frame.data[0][iy[3] + 1] = codebook->y3;
+ if (!s->palette_video) {
+ s->frame.data[1][iu[1]] = codebook->u;
+ s->frame.data[2][iv[1]] = codebook->v;
+ }
+
+ codebook = &strip->v4_codebook[*data++];
+ s->frame.data[0][iy[2] + 2] = codebook->y0;
+ s->frame.data[0][iy[2] + 3] = codebook->y1;
+ s->frame.data[0][iy[3] + 2] = codebook->y2;
+ s->frame.data[0][iy[3] + 3] = codebook->y3;
+ if (!s->palette_video) {
+ s->frame.data[1][iu[1] + 1] = codebook->u;
+ s->frame.data[2][iv[1] + 1] = codebook->v;
+ }
+
+ }
+ } else {
+ /* copy from the previous frame */
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 4; j++) {
+ s->frame.data[0][iy[i] + j] =
+ s->prev_frame.data[0][iy[i] + j];
+ }
+ }
+ for (i = 0; i < 2; i++) {
+ for (j = 0; j < 2; j++) {
+ s->frame.data[1][iu[i] + j] =
+ s->prev_frame.data[1][iu[i] + j];
+ s->frame.data[2][iv[i] + j] =
+ s->prev_frame.data[2][iv[i] + j];
+ }
+ }
+ }
+
+ iy[0] += 4; iy[1] += 4;
+ iy[2] += 4; iy[3] += 4;
+ iu[0] += 2; iu[1] += 2;
+ iv[0] += 2; iv[1] += 2;
+ }
+ }
+
+ return 0;
+}
+
+static int cinepak_decode_strip (CinepakContext *s,
+ cvid_strip_t *strip, uint8_t *data, int size)
+{
+ uint8_t *eod = (data + size);
+ int chunk_id, chunk_size;
+
+ /* coordinate sanity checks */
+ if (strip->x1 >= s->width || strip->x2 > s->width ||
+ strip->y1 >= s->height || strip->y2 > s->height ||
+ strip->x1 >= strip->x2 || strip->y1 >= strip->y2)
+ return -1;
+
+ while ((data + 4) <= eod) {
+ chunk_id = BE_16 (&data[0]);
+ chunk_size = BE_16 (&data[2]) - 4;
+ data += 4;
+ chunk_size = ((data + chunk_size) > eod) ? (eod - data) : chunk_size;
+
+ switch (chunk_id) {
+
+ case 0x2000:
+ case 0x2100:
+ case 0x2400:
+ case 0x2500:
+ cinepak_decode_codebook (strip->v4_codebook, chunk_id,
+ chunk_size, data);
+ break;
+
+ case 0x2200:
+ case 0x2300:
+ case 0x2600:
+ case 0x2700:
+ cinepak_decode_codebook (strip->v1_codebook, chunk_id,
+ chunk_size, data);
+ break;
+
+ case 0x3000:
+ case 0x3100:
+ case 0x3200:
+ return cinepak_decode_vectors (s, strip, chunk_id,
+ chunk_size, data);
+ }
+
+ data += chunk_size;
+ }
+
+ return -1;
+}
+
+static int cinepak_decode (CinepakContext *s)
+{
+ uint8_t *eod = (s->data + s->size);
+ int i, result, strip_size, frame_flags, num_strips;
+ int y0 = 0;
+
+ if (s->size < 10)
+ return -1;
+
+ frame_flags = s->data[0];
+ num_strips = BE_16 (&s->data[8]);
+ s->data += 10;
+
+ if (num_strips > MAX_STRIPS)
+ num_strips = MAX_STRIPS;
+
+ for (i=0; i < num_strips; i++) {
+ if ((s->data + 12) > eod)
+ return -1;
+
+ s->strips[i].id = BE_16 (s->data);
+ s->strips[i].y1 = y0;
+ s->strips[i].x1 = 0;
+ s->strips[i].y2 = y0 + BE_16 (&s->data[8]);
+ s->strips[i].x2 = s->avctx->width;
+
+ strip_size = BE_16 (&s->data[2]) - 12;
+ s->data += 12;
+ strip_size = ((s->data + strip_size) > eod) ? (eod - s->data) : strip_size;
+
+ if ((i > 0) && !(frame_flags & 0x01)) {
+ memcpy (s->strips[i].v4_codebook, s->strips[i-1].v4_codebook,
+ sizeof(s->strips[i].v4_codebook));
+ memcpy (s->strips[i].v1_codebook, s->strips[i-1].v1_codebook,
+ sizeof(s->strips[i].v1_codebook));
+ }
+
+ result = cinepak_decode_strip (s, &s->strips[i], s->data, strip_size);
+
+ if (result != 0)
+ return result;
+
+ s->data += strip_size;
+ y0 = s->strips[i].y2;
+ }
+ return 0;
+}
+
+static int cinepak_decode_init(AVCodecContext *avctx)
+{
+ CinepakContext *s = (CinepakContext *)avctx->priv_data;
+/*
+ int i;
+ unsigned char r, g, b;
+ unsigned char *raw_palette;
+ unsigned int *palette32;
+*/
+
+ s->avctx = avctx;
+ s->width = (avctx->width + 3) & ~3;
+ s->height = (avctx->height + 3) & ~3;
+
+// check for paletted data
+s->palette_video = 0;
+
+
+ avctx->pix_fmt = PIX_FMT_YUV420P;
+ avctx->has_b_frames = 0;
+ dsputil_init(&s->dsp, avctx);
+
+ s->frame.data[0] = s->prev_frame.data[0] = NULL;
+
+ return 0;
+}
+
+static int cinepak_decode_frame(AVCodecContext *avctx,
+ void *data, int *data_size,
+ uint8_t *buf, int buf_size)
+{
+ CinepakContext *s = (CinepakContext *)avctx->priv_data;
+
+ s->data = buf;
+ s->size = buf_size;
+
+ if (avctx->get_buffer(avctx, &s->frame)) {
+ printf (" Cinepak: get_buffer() failed\n");
+ return -1;
+ }
+
+ cinepak_decode(s);
+
+ if (s->prev_frame.data[0])
+ avctx->release_buffer(avctx, &s->prev_frame);
+
+ /* shuffle frames */
+ s->prev_frame = s->frame;
+
+ *data_size = sizeof(AVFrame);
+ *(AVFrame*)data = s->frame;
+
+ /* report that the buffer was completely consumed */
+ return buf_size;
+}
+
+static int cinepak_decode_end(AVCodecContext *avctx)
+{
+ CinepakContext *s = (CinepakContext *)avctx->priv_data;
+
+ if (s->prev_frame.data[0])
+ avctx->release_buffer(avctx, &s->prev_frame);
+
+ return 0;
+}
+
+AVCodec cinepak_decoder = {
+ "cinepak",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_CINEPAK,
+ sizeof(CinepakContext),
+ cinepak_decode_init,
+ NULL,
+ cinepak_decode_end,
+ cinepak_decode_frame,
+ CODEC_CAP_DR1,
+};
diff --git a/src/libffmpeg/libavcodec/common.c b/src/libffmpeg/libavcodec/common.c
index 0e6cd69d0..f37c2c9eb 100644
--- a/src/libffmpeg/libavcodec/common.c
+++ b/src/libffmpeg/libavcodec/common.c
@@ -44,18 +44,11 @@ const uint8_t ff_log2_tab[256]={
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
};
-void init_put_bits(PutBitContext *s,
- uint8_t *buffer, int buffer_size,
- void *opaque,
- void (*write_data)(void *, uint8_t *, int))
+void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
{
s->buf = buffer;
s->buf_end = s->buf + buffer_size;
s->data_out_size = 0;
- if(write_data!=NULL)
- {
- fprintf(stderr, "write Data callback is not supported\n");
- }
#ifdef ALT_BITSTREAM_WRITER
s->index=0;
((uint32_t*)(s->buf))[0]=0;
@@ -293,7 +286,7 @@ static int build_table(VLC *vlc, int table_nb_bits,
#endif
if (table[j][1] /*bits*/ != 0) {
fprintf(stderr, "incorrect codes\n");
- exit(1);
+ av_abort();
}
table[j][1] = n; //bits
table[j][0] = i; //code
@@ -393,29 +386,3 @@ int64_t ff_gcd(int64_t a, int64_t b){
if(b) return ff_gcd(b, a%b);
else return a;
}
-
-void ff_float2fraction(int *nom_arg, int *denom_arg, double f, int max){
- double best_diff=1E10, diff;
- int best_denom=1, best_nom=1;
- int nom, denom, gcd;
-
- //brute force here, perhaps we should try continued fractions if we need large max ...
- for(denom=1; denom<=max; denom++){
- nom= (int)(f*denom + 0.5);
- if(nom<=0 || nom>max) continue;
-
- diff= ABS( f - (double)nom / (double)denom );
- if(diff < best_diff){
- best_diff= diff;
- best_nom= nom;
- best_denom= denom;
- }
- }
-
- gcd= ff_gcd(best_nom, best_denom);
- best_nom /= gcd;
- best_denom /= gcd;
-
- *nom_arg= best_nom;
- *denom_arg= best_denom;
-}
diff --git a/src/libffmpeg/libavcodec/common.h b/src/libffmpeg/libavcodec/common.h
index 5cbda9126..96dc443bd 100644
--- a/src/libffmpeg/libavcodec/common.h
+++ b/src/libffmpeg/libavcodec/common.h
@@ -25,6 +25,7 @@
# include <stdlib.h>
# include <stdio.h>
# include <string.h>
+# include <ctype.h>
# ifndef __BEOS__
# include <errno.h>
# else
@@ -98,19 +99,23 @@ typedef signed __int64 int64_t;
# define int64_t_C(c) (c ## i64)
# define uint64_t_C(c) (c ## i64)
-# define inline __inline
+# ifdef HAVE_AV_CONFIG_H
+# define inline __inline
+# endif
# else
# define int64_t_C(c) (c ## LL)
# define uint64_t_C(c) (c ## ULL)
# endif /* __MINGW32__ */
-# ifdef _DEBUG
-# define DEBUG
-# endif
+# ifdef HAVE_AV_CONFIG_H
+# ifdef _DEBUG
+# define DEBUG
+# endif
-# define snprintf _snprintf
-# define vsnprintf _vsnprintf
+# define snprintf _snprintf
+# define vsnprintf _vsnprintf
+# endif
/* CONFIG_WIN32 end */
#elif defined (CONFIG_OS2)
@@ -118,13 +123,13 @@ typedef signed __int64 int64_t;
#include <inttypes.h>
-#ifdef HAVE_AV_CONFIG_H
-
#ifndef int64_t_C
#define int64_t_C(c) (c ## LL)
#define uint64_t_C(c) (c ## ULL)
#endif
+#ifdef HAVE_AV_CONFIG_H
+
#ifdef USE_FASTMEMCPY
#include "fastmemcpy.h"
#endif
@@ -138,13 +143,14 @@ typedef signed __int64 int64_t;
/* unix */
-# include <inttypes.h>
+#include <inttypes.h>
-# ifdef HAVE_AV_CONFIG_H
-# ifndef int64_t_C
-# define int64_t_C(c) (c ## LL)
-# define uint64_t_C(c) (c ## ULL)
-# endif
+#ifndef int64_t_C
+#define int64_t_C(c) (c ## LL)
+#define uint64_t_C(c) (c ## ULL)
+#endif
+
+#ifdef HAVE_AV_CONFIG_H
# ifdef USE_FASTMEMCPY
# include "fastmemcpy.h"
@@ -263,10 +269,7 @@ typedef struct PutBitContext {
int64_t data_out_size; /* in bytes */
} PutBitContext;
-void init_put_bits(PutBitContext *s,
- uint8_t *buffer, int buffer_size,
- void *opaque,
- void (*write_data)(void *, uint8_t *, int));
+void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size);
int64_t get_bit_count(PutBitContext *s); /* XXX: change function name */
void align_put_bits(PutBitContext *s);
@@ -350,23 +353,14 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value)
bit_buf = s->bit_buf;
bit_left = s->bit_left;
- assert(bit_left >= 0 && bit_left <= 32);
-
// printf("n=%d value=%x cnt=%d buf=%x\n", n, value, bit_cnt, bit_buf);
/* XXX: optimize */
if (n < bit_left) {
- if (n == 32)
- bit_buf = value;
- else
- bit_buf = (bit_buf<<n) | value;
+ bit_buf = (bit_buf<<n) | value;
bit_left-=n;
} else {
- if (bit_left == 32)
- bit_buf=0;
- else
- bit_buf<<=bit_left;
- if (n - bit_left < 32)
- bit_buf |= value >> (n - bit_left);
+ bit_buf<<=bit_left;
+ bit_buf |= value >> (n - bit_left);
#ifdef UNALIGNED_STORES_ARE_BAD
if (3 & (int) s->buf_ptr) {
s->buf_ptr[0] = bit_buf >> 24;
@@ -1062,7 +1056,7 @@ static inline int ff_sqrt(int a)
*/
static inline int ff_get_fourcc(const char *s){
assert( strlen(s)==4 );
-
+
return (s[0]) + (s[1]<<8) + (s[2]<<16) + (s[3]<<24);
}
@@ -1070,9 +1064,6 @@ static inline int ff_get_fourcc(const char *s){
#define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24))
-void ff_float2fraction(int *nom_arg, int *denom_arg, double f, int max);
-
-
#ifdef ARCH_X86
#define MASK_ABS(mask, level)\
asm volatile(\
@@ -1146,7 +1137,7 @@ if(256*256*256*64%(tcount+tskip_count)==0){\
#define CHECKED_ALLOCZ(p, size)\
{\
p= av_mallocz(size);\
- if(p==NULL){\
+ if(p==NULL && (size)!=0){\
perror("malloc");\
goto fail;\
}\
diff --git a/src/libffmpeg/libavcodec/dpcm.c b/src/libffmpeg/libavcodec/dpcm.c
new file mode 100644
index 000000000..ef4ccf886
--- /dev/null
+++ b/src/libffmpeg/libavcodec/dpcm.c
@@ -0,0 +1,245 @@
+/*
+ * Assorted DPCM codecs
+ * 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
+ */
+
+/**
+ * @file: dpcm.c
+ * Assorted DPCM (differential pulse code modulation) audio codecs
+ * by Mike Melanson (melanson@pcisys.net)
+ * Xan DPCM decoder by Mario Brito (mbrito@student.dei.uc.pt)
+ * for more information on the specific data formats, visit:
+ * http://www.pcisys.net/~melanson/codecs/simpleaudio.html
+ *
+ * Note about using the Xan DPCM decoder: Xan DPCM is used in AVI files
+ * found in the Wing Commander IV computer game. These AVI files contain
+ * WAVEFORMAT headers which report the audio format as 0x01: raw PCM.
+ * Clearly incorrect. To detect Xan DPCM, you will probably have to
+ * special-case your AVI demuxer to use Xan DPCM if the file uses 'Xxan'
+ * (Xan video) for its video codec. Alternately, such AVI files also contain
+ * the fourcc 'Axan' in the 'auds' chunk of the AVI header.
+ */
+
+#include "avcodec.h"
+
+typedef struct DPCMContext {
+ int channels;
+ short roq_square_array[256];
+} DPCMContext;
+
+#define SATURATE_S16(x) if (x < -32768) x = -32768; \
+ else if (x > 32767) x = 32767;
+#define SE_16BIT(x) if (x & 0x8000) x -= 0x10000;
+#define LE_16(x) ((((uint8_t*)(x))[1] << 8) | ((uint8_t*)(x))[0])
+#define LE_32(x) ((((uint8_t*)(x))[3] << 24) | \
+ (((uint8_t*)(x))[2] << 16) | \
+ (((uint8_t*)(x))[1] << 8) | \
+ ((uint8_t*)(x))[0])
+
+static int interplay_delta_table[] = {
+ 0, 1, 2, 3, 4, 5, 6, 7,
+ 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31,
+ 32, 33, 34, 35, 36, 37, 38, 39,
+ 40, 41, 42, 43, 47, 51, 56, 61,
+ 66, 72, 79, 86, 94, 102, 112, 122,
+ 133, 145, 158, 173, 189, 206, 225, 245,
+ 267, 292, 318, 348, 379, 414, 452, 493,
+ 538, 587, 640, 699, 763, 832, 908, 991,
+ 1081, 1180, 1288, 1405, 1534, 1673, 1826, 1993,
+ 2175, 2373, 2590, 2826, 3084, 3365, 3672, 4008,
+ 4373, 4772, 5208, 5683, 6202, 6767, 7385, 8059,
+ 8794, 9597, 10472, 11428, 12471, 13609, 14851, 16206,
+ 17685, 19298, 21060, 22981, 25078, 27367, 29864, 32589,
+ -29973, -26728, -23186, -19322, -15105, -10503, -5481, -1,
+ 1, 1, 5481, 10503, 15105, 19322, 23186, 26728,
+ 29973, -32589, -29864, -27367, -25078, -22981, -21060, -19298,
+ -17685, -16206, -14851, -13609, -12471, -11428, -10472, -9597,
+ -8794, -8059, -7385, -6767, -6202, -5683, -5208, -4772,
+ -4373, -4008, -3672, -3365, -3084, -2826, -2590, -2373,
+ -2175, -1993, -1826, -1673, -1534, -1405, -1288, -1180,
+ -1081, -991, -908, -832, -763, -699, -640, -587,
+ -538, -493, -452, -414, -379, -348, -318, -292,
+ -267, -245, -225, -206, -189, -173, -158, -145,
+ -133, -122, -112, -102, -94, -86, -79, -72,
+ -66, -61, -56, -51, -47, -43, -42, -41,
+ -40, -39, -38, -37, -36, -35, -34, -33,
+ -32, -31, -30, -29, -28, -27, -26, -25,
+ -24, -23, -22, -21, -20, -19, -18, -17,
+ -16, -15, -14, -13, -12, -11, -10, -9,
+ -8, -7, -6, -5, -4, -3, -2, -1
+
+};
+
+static int dpcm_decode_init(AVCodecContext *avctx)
+{
+ DPCMContext *s = avctx->priv_data;
+ int i;
+ short square;
+
+ s->channels = avctx->channels;
+
+ switch(avctx->codec->id) {
+
+ case CODEC_ID_ROQ_DPCM:
+ /* initialize square table */
+ for (i = 0; i < 128; i++) {
+ square = i * i;
+ s->roq_square_array[i] = square;
+ s->roq_square_array[i + 128] = -square;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+static int dpcm_decode_frame(AVCodecContext *avctx,
+ void *data, int *data_size,
+ uint8_t *buf, int buf_size)
+{
+ DPCMContext *s = avctx->priv_data;
+ int in, out = 0;
+ int predictor[2];
+ int channel_number = 0;
+ short *output_samples = data;
+ int shift[2];
+ unsigned char byte;
+ short diff;
+
+ switch(avctx->codec->id) {
+
+ case CODEC_ID_ROQ_DPCM:
+ if (s->channels == 1)
+ predictor[0] = LE_16(&buf[6]);
+ else {
+ predictor[0] = buf[7] << 8;
+ predictor[1] = buf[6] << 8;
+ }
+ SE_16BIT(predictor[0]);
+ SE_16BIT(predictor[1]);
+
+ /* decode the samples */
+ for (in = 8, out = 0; in < buf_size; in++, out++) {
+ predictor[channel_number] += s->roq_square_array[buf[in]];
+ SATURATE_S16(predictor[channel_number]);
+ output_samples[out] = predictor[channel_number];
+
+ /* toggle channel */
+ channel_number ^= s->channels - 1;
+ }
+ break;
+
+ case CODEC_ID_INTERPLAY_DPCM:
+ in = 6; /* skip over the stream mask and stream length */
+ predictor[0] = LE_16(&buf[in]);
+ in += 2;
+ SE_16BIT(predictor[0])
+ output_samples[out++] = predictor[0];
+ if (s->channels == 2) {
+ predictor[1] = LE_16(&buf[in]);
+ in += 2;
+ SE_16BIT(predictor[1])
+ output_samples[out++] = predictor[1];
+ }
+
+ while (in < buf_size) {
+ predictor[channel_number] += interplay_delta_table[buf[in++]];
+ SATURATE_S16(predictor[channel_number]);
+ output_samples[out++] = predictor[channel_number];
+
+ /* toggle channel */
+ channel_number ^= s->channels - 1;
+ }
+
+ break;
+
+ case CODEC_ID_XAN_DPCM:
+ in = 0;
+ shift[0] = shift[1] = 4;
+ predictor[0] = LE_16(&buf[in]);
+ in += 2;
+ SE_16BIT(predictor[0]);
+ if (s->channels == 2) {
+ predictor[1] = LE_16(&buf[in]);
+ in += 2;
+ SE_16BIT(predictor[1]);
+ }
+
+ while (in < buf_size) {
+ byte = buf[in++];
+ diff = (byte & 0xFC) << 8;
+ if ((byte & 0x03) == 3)
+ shift[channel_number]++;
+ else
+ shift[channel_number] -= (2 * (byte & 3));
+ /* saturate the shifter to a lower limit of 0 */
+ if (shift[channel_number] < 0)
+ shift[channel_number] = 0;
+
+ diff >>= shift[channel_number];
+ predictor[channel_number] += diff;
+
+ SATURATE_S16(predictor[channel_number]);
+ output_samples[out++] = predictor[channel_number];
+
+ /* toggle channel */
+ channel_number ^= s->channels - 1;
+ }
+ break;
+ }
+
+ *data_size = out * sizeof(short);
+ return buf_size;
+}
+
+AVCodec roq_dpcm_decoder = {
+ "roq_dpcm",
+ CODEC_TYPE_AUDIO,
+ CODEC_ID_ROQ_DPCM,
+ sizeof(DPCMContext),
+ dpcm_decode_init,
+ NULL,
+ NULL,
+ dpcm_decode_frame,
+};
+
+AVCodec interplay_dpcm_decoder = {
+ "interplay_dpcm",
+ CODEC_TYPE_AUDIO,
+ CODEC_ID_INTERPLAY_DPCM,
+ sizeof(DPCMContext),
+ dpcm_decode_init,
+ NULL,
+ NULL,
+ dpcm_decode_frame,
+};
+
+AVCodec xan_dpcm_decoder = {
+ "xan_dpcm",
+ CODEC_TYPE_AUDIO,
+ CODEC_ID_XAN_DPCM,
+ sizeof(DPCMContext),
+ dpcm_decode_init,
+ NULL,
+ NULL,
+ dpcm_decode_frame,
+};
diff --git a/src/libffmpeg/libavcodec/dsputil.c b/src/libffmpeg/libavcodec/dsputil.c
index 810fb9b0f..270424706 100644
--- a/src/libffmpeg/libavcodec/dsputil.c
+++ b/src/libffmpeg/libavcodec/dsputil.c
@@ -2526,6 +2526,24 @@ static void diff_bytes_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){
dst[i+0] = src1[i+0]-src2[i+0];
}
+static void sub_hfyu_median_prediction_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w, int *left, int *left_top){
+ int i;
+ uint8_t l, lt;
+
+ l= *left;
+ lt= *left_top;
+
+ for(i=0; i<w; i++){
+ const int pred= mid_pred(l, src1[i], (l + src1[i] - lt)&0xFF);
+ lt= src1[i];
+ l= src2[i];
+ dst[i]= l - pred;
+ }
+
+ *left= l;
+ *left_top= lt;
+}
+
#define BUTTERFLY2(o1,o2,i1,i2) \
o1= (i1)+(i2);\
o2= (i1)-(i2);
@@ -2860,10 +2878,12 @@ void dsputil_init(DSPContext* c, AVCodecContext *avctx)
if(avctx->idct_algo==FF_IDCT_INT){
c->idct_put= ff_jref_idct_put;
c->idct_add= ff_jref_idct_add;
+ c->idct = j_rev_dct;
c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;
}else{ //accurate/default
c->idct_put= simple_idct_put;
c->idct_add= simple_idct_add;
+ c->idct = simple_idct;
c->idct_permutation_type= FF_NO_IDCT_PERM;
}
@@ -3005,6 +3025,7 @@ void dsputil_init(DSPContext* c, AVCodecContext *avctx)
c->add_bytes= add_bytes_c;
c->diff_bytes= diff_bytes_c;
+ c->sub_hfyu_median_prediction= sub_hfyu_median_prediction_c;
c->bswap_buf= bswap_buf;
#ifdef HAVE_MMX
diff --git a/src/libffmpeg/libavcodec/dsputil.h b/src/libffmpeg/libavcodec/dsputil.h
index 5dddfbe3e..6126c78b5 100644
--- a/src/libffmpeg/libavcodec/dsputil.h
+++ b/src/libffmpeg/libavcodec/dsputil.h
@@ -39,7 +39,6 @@
/* dct code */
typedef short DCTELEM;
-//typedef int DCTELEM;
void fdct_ifast (DCTELEM *data);
void ff_jpeg_fdct_islow (DCTELEM *data);
@@ -167,7 +166,7 @@ typedef struct DSPContext {
/**
* Halfpel motion compensation with rounding (a+b+1)>>1.
- * this is an array[4][4] of motion compensation functions for 4
+ * This is an array[4][4] of motion compensation functions 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
@@ -212,7 +211,7 @@ typedef struct DSPContext {
*/
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];
@@ -240,11 +239,19 @@ 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);
+ /**
+ * subtract huffyuv's variant of median prediction
+ * note, this might read from src1[-1], src2[-1]
+ */
+ void (*sub_hfyu_median_prediction)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w, int *left, int *left_top);
void (*bswap_buf)(uint32_t *dst, uint32_t *src, int w);
/* (I)DCT */
void (*fdct)(DCTELEM *block/* align 16*/);
+ /* IDCT really*/
+ void (*idct)(DCTELEM *block/* align 16*/);
+
/**
* block -> idct -> clip to unsigned 8 bit -> dest.
* (-1392, 0, 0, ...) -> idct -> (-174, -174, ...) -> put -> (0, 0, ...)
@@ -499,4 +506,10 @@ static inline long int lrintf(float x)
}
#endif
+#if defined(CONFIG_OS2) || defined(CONFIG_SUNOS)
+static inline float floorf(float f) {
+ return floor(f);
+}
+#endif
+
#endif
diff --git a/src/libffmpeg/libavcodec/dv.c b/src/libffmpeg/libavcodec/dv.c
index d454e61e6..c969e937b 100644
--- a/src/libffmpeg/libavcodec/dv.c
+++ b/src/libffmpeg/libavcodec/dv.c
@@ -2,6 +2,12 @@
* DV decoder
* Copyright (c) 2002 Fabrice Bellard.
*
+ * DV encoder
+ * Copyright (c) 2003 Roman Shaposhnik.
+ *
+ * Many thanks to Dan Dennedy <dan@dennedy.org> for providing wealth
+ * of DV technical info.
+ *
* 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
@@ -19,40 +25,35 @@
/**
* @file dv.c
- * DV decoder.
+ * DV codec.
*/
#include "avcodec.h"
#include "dsputil.h"
#include "mpegvideo.h"
#include "simple_idct.h"
-
-#define NTSC_FRAME_SIZE 120000
-#define PAL_FRAME_SIZE 144000
-
-#define TEX_VLC_BITS 9
+#include "dvdata.h"
typedef struct DVVideoDecodeContext {
- AVCodecContext *avctx;
+ const DVprofile* sys;
GetBitContext gb;
- VLC *vlc;
- int sampling_411; /* 0 = 420, 1 = 411 */
- int width, height;
- uint8_t *current_picture[3]; /* picture structure */
AVFrame picture;
- int linesize[3];
DCTELEM block[5*6][64] __align8;
+
+ /* FIXME: the following is extracted from DSP */
uint8_t dv_zigzag[2][64];
uint8_t idct_permutation[64];
+ void (*get_pixels)(DCTELEM *block, const uint8_t *pixels, int line_size);
+ void (*fdct)(DCTELEM *block);
+
/* XXX: move it to static storage ? */
uint8_t dv_shift[2][22][64];
void (*idct_put[2])(uint8_t *dest, int line_size, DCTELEM *block);
} DVVideoDecodeContext;
-#include "dvdata.h"
-
-static VLC dv_vlc;
+#define TEX_VLC_BITS 9
/* XXX: also include quantization */
static RL_VLC_ELEM *dv_rl_vlc[1];
+static VLC_TYPE dv_vlc_codes[15][23];
static void dv_build_unquantize_tables(DVVideoDecodeContext *s)
{
@@ -77,7 +78,7 @@ static void dv_build_unquantize_tables(DVVideoDecodeContext *s)
}
}
-static int dvvideo_decode_init(AVCodecContext *avctx)
+static int dvvideo_init(AVCodecContext *avctx)
{
DVVideoDecodeContext *s = avctx->priv_data;
MpegEncContext s2;
@@ -85,6 +86,7 @@ static int dvvideo_decode_init(AVCodecContext *avctx)
if (!done) {
int i;
+ VLC dv_vlc;
done = 1;
@@ -114,6 +116,12 @@ static int dvvideo_decode_init(AVCodecContext *avctx)
dv_rl_vlc[0][i].level = level;
dv_rl_vlc[0][i].run = run;
}
+
+ memset(dv_vlc_codes, 0xff, sizeof(dv_vlc_codes));
+ for (i = 0; i < NB_DV_VLC - 1; i++) {
+ if (dv_vlc_run[i] < 15 && dv_vlc_level[i] < 23 && dv_vlc_len[i] < 15)
+ dv_vlc_codes[dv_vlc_run[i]][dv_vlc_level[i]] = i;
+ }
}
/* ugly way to get the idct & scantable */
@@ -124,6 +132,9 @@ static int dvvideo_decode_init(AVCodecContext *avctx)
if (DCT_common_init(&s2) < 0)
return -1;
+ s->get_pixels = s2.dsp.get_pixels;
+ s->fdct = s2.dsp.fdct;
+
s->idct_put[0] = s2.dsp.idct_put;
memcpy(s->idct_permutation, s2.dsp.idct_permutation, 64);
memcpy(s->dv_zigzag[0], s2.intra_scantable.permutated, 64);
@@ -134,11 +145,16 @@ static int dvvideo_decode_init(AVCodecContext *avctx)
/* XXX: do it only for constant case */
dv_build_unquantize_tables(s);
+
+ /* FIXME: I really don't think this should be here */
+ if (dv_codec_profile(avctx))
+ avctx->pix_fmt = dv_codec_profile(avctx)->pix_fmt;
+ avctx->coded_frame = &s->picture;
return 0;
}
-//#define VLC_DEBUG
+// #define VLC_DEBUG
typedef struct BlockInfo {
const uint8_t *shift_table;
@@ -329,13 +345,13 @@ static inline void dv_decode_video_segment(DVVideoDecodeContext *s,
buf_ptr = buf_ptr1;
block1 = &s->block[0][0];
mb1 = mb_data;
- init_put_bits(&vs_pb, vs_bit_buffer, 5 * 80, NULL, NULL);
+ init_put_bits(&vs_pb, vs_bit_buffer, 5 * 80);
vs_bit_count = 0;
for(mb_index = 0; mb_index < 5; mb_index++) {
/* skip header */
quant = buf_ptr[3] & 0x0f;
buf_ptr += 4;
- init_put_bits(&pb, mb_bit_buffer, 80, NULL, NULL);
+ init_put_bits(&pb, mb_bit_buffer, 80);
mb_bit_count = 0;
mb = mb1;
block = block1;
@@ -363,6 +379,9 @@ static inline void dv_decode_video_segment(DVVideoDecodeContext *s,
mb->pos = 0;
mb->partial_bit_count = 0;
+#ifdef VLC_DEBUG
+ printf("MB block: %d, %d ", mb_index, j);
+#endif
dv_decode_ac(s, mb, block, last_index);
/* write the remaining bits in a new buffer only if the
@@ -386,7 +405,7 @@ static inline void dv_decode_video_segment(DVVideoDecodeContext *s,
/* pass 2 : we can do it just after */
#ifdef VLC_DEBUG
- printf("***pass 2 size=%d\n", mb_bit_count);
+ printf("***pass 2 size=%d MB#=%d\n", mb_bit_count, mb_index);
#endif
block = block1;
mb = mb1;
@@ -450,29 +469,31 @@ static inline void dv_decode_video_segment(DVVideoDecodeContext *s,
v = *mb_pos_ptr++;
mb_x = v & 0xff;
mb_y = v >> 8;
- y_ptr = s->current_picture[0] + (mb_y * s->linesize[0] * 8) + (mb_x * 8);
- if (s->sampling_411)
- c_offset = (mb_y * s->linesize[1] * 8) + ((mb_x >> 2) * 8);
+ y_ptr = s->picture.data[0] + (mb_y * s->picture.linesize[0] * 8) + (mb_x * 8);
+ if (s->sys->pix_fmt == PIX_FMT_YUV411P)
+ c_offset = (mb_y * s->picture.linesize[1] * 8) + ((mb_x >> 2) * 8);
else
- c_offset = ((mb_y >> 1) * s->linesize[1] * 8) + ((mb_x >> 1) * 8);
+ c_offset = ((mb_y >> 1) * s->picture.linesize[1] * 8) + ((mb_x >> 1) * 8);
for(j = 0;j < 6; j++) {
idct_put = s->idct_put[mb->dct_mode];
if (j < 4) {
- if (s->sampling_411 && mb_x < (704 / 8)) {
+ if (s->sys->pix_fmt == PIX_FMT_YUV411P && mb_x < (704 / 8)) {
/* NOTE: at end of line, the macroblock is handled as 420 */
- idct_put(y_ptr + (j * 8), s->linesize[0], block);
+ idct_put(y_ptr + (j * 8), s->picture.linesize[0], block);
} else {
- idct_put(y_ptr + ((j & 1) * 8) + ((j >> 1) * 8 * s->linesize[0]),
- s->linesize[0], block);
+ idct_put(y_ptr + ((j & 1) * 8) + ((j >> 1) * 8 * s->picture.linesize[0]),
+ s->picture.linesize[0], block);
}
} else {
- if (s->sampling_411 && mb_x >= (704 / 8)) {
- uint8_t pixels[64], *c_ptr, *c_ptr1, *ptr;
+ if (s->sys->pix_fmt == PIX_FMT_YUV411P && mb_x >= (704 / 8)) {
+ uint64_t aligned_pixels[64/8];
+ uint8_t *pixels= (uint8_t*)aligned_pixels;
+ uint8_t *c_ptr, *c_ptr1, *ptr;
int y, linesize;
/* NOTE: at end of line, the macroblock is handled as 420 */
idct_put(pixels, 8, block);
- linesize = s->linesize[6 - j];
- c_ptr = s->current_picture[6 - j] + c_offset;
+ linesize = s->picture.linesize[6 - j];
+ c_ptr = s->picture.data[6 - j] + c_offset;
ptr = pixels;
for(y = 0;y < 8; y++) {
/* convert to 411P */
@@ -486,8 +507,8 @@ static inline void dv_decode_video_segment(DVVideoDecodeContext *s,
}
} else {
/* don't ask me why they inverted Cb and Cr ! */
- idct_put(s->current_picture[6 - j] + c_offset,
- s->linesize[6 - j], block);
+ idct_put(s->picture.data[6 - j] + c_offset,
+ s->picture.linesize[6 - j], block);
}
}
block += 64;
@@ -496,309 +517,424 @@ static inline void dv_decode_video_segment(DVVideoDecodeContext *s,
}
}
-
-/* NOTE: exactly one frame must be given (120000 bytes for NTSC,
- 144000 bytes for PAL) */
-static int dvvideo_decode_frame(AVCodecContext *avctx,
- void *data, int *data_size,
- uint8_t *buf, int buf_size)
+/* Converts run and level (where level != 0) pair into vlc, returning bit size */
+static inline int dv_rl2vlc(int run, int l, uint32_t* vlc)
{
- DVVideoDecodeContext *s = avctx->priv_data;
- int sct, dsf, apt, ds, nb_dif_segs, vs, width, height, i, packet_size;
- uint8_t *buf_ptr;
- const uint16_t *mb_pos_ptr;
+ int sign = l >> 8;
+ int level = (l ^ sign) - sign;
+ int size;
- /* parse id */
- init_get_bits(&s->gb, buf, buf_size*8);
- sct = get_bits(&s->gb, 3);
- if (sct != 0)
- return -1;
- skip_bits(&s->gb, 5);
- get_bits(&s->gb, 4); /* dsn (sequence number */
- get_bits(&s->gb, 1); /* fsc (channel number) */
- skip_bits(&s->gb, 3);
- get_bits(&s->gb, 8); /* dbn (diff block number 0-134) */
-
- dsf = get_bits(&s->gb, 1); /* 0 = NTSC 1 = PAL */
- if (get_bits(&s->gb, 1) != 0)
- return -1;
- skip_bits(&s->gb, 11);
- apt = get_bits(&s->gb, 3); /* apt */
+ sign = (sign & 1);
- get_bits(&s->gb, 1); /* tf1 */
- skip_bits(&s->gb, 4);
- get_bits(&s->gb, 3); /* ap1 */
+ if (run < 15 && level < 23 && dv_vlc_codes[run][level] != -1) {
+ *vlc = (dv_vlc_bits[dv_vlc_codes[run][level]] << 1) | sign;
+ size = dv_vlc_len[dv_vlc_codes[run][level]] + 1;
+ }
+ else {
+ if (level < 23) {
+ *vlc = (dv_vlc_bits[dv_vlc_codes[0][level]] << 1) | sign;
+ size = dv_vlc_len[dv_vlc_codes[0][level]] + 1;
+ } else {
+ *vlc = 0xfe00 | (level << 1) | sign;
+ size = 16;
+ }
+
+ switch(run) {
+ case 0:
+ break;
+ case 1:
+ case 2:
+ *vlc |= ((0x7ce | (run - 1)) << size);
+ size += 11;
+ break;
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ *vlc |= ((0xfac | (run - 3)) << size);
+ size += 12;
+ break;
+ default:
+ *vlc |= ((0x1f80 | (run - 1)) << size);
+ size += 13;
+ break;
+ }
+ }
+
+ return size;
+}
- get_bits(&s->gb, 1); /* tf2 */
- skip_bits(&s->gb, 4);
- get_bits(&s->gb, 3); /* ap2 */
+typedef struct EncBlockInfo {
+ int qno;
+ int cno;
+ int dct_mode;
+ int block_size;
+ DCTELEM *mb;
+ PutBitContext pb;
+} EncBlockInfo;
- get_bits(&s->gb, 1); /* tf3 */
- skip_bits(&s->gb, 4);
- get_bits(&s->gb, 3); /* ap3 */
+static inline int dv_bits_left(EncBlockInfo* bi)
+{
+ return (bi->block_size - get_bit_count(&bi->pb));
+}
+
+static inline void dv_encode_ac(EncBlockInfo* bi, PutBitContext* heap)
+{
+ int i, level, size, run = 0;
+ uint32_t vlc;
+ PutBitContext* cpb = &bi->pb;
- /* init size */
- width = 720;
- if (dsf) {
- avctx->frame_rate = 25;
- avctx->frame_rate_base = 1;
- packet_size = PAL_FRAME_SIZE;
- height = 576;
- nb_dif_segs = 12;
- } else {
- avctx->frame_rate = 30000;
- avctx->frame_rate_base = 1001;
- packet_size = NTSC_FRAME_SIZE;
- height = 480;
- nb_dif_segs = 10;
+ for (i=1; i<64; i++) {
+ level = bi->mb[ff_zigzag_direct[i]] /
+ (1<<(dv_quant_shifts[bi->qno + dv_quant_offset[bi->cno]]
+ [dv_88_areas[ff_zigzag_direct[i]]] + 4 + (bi->cno == 3)));
+ if (level != 0) {
+ size = dv_rl2vlc(run, level, &vlc);
+put_vlc:
+
+#ifdef VLC_DEBUG
+ printf(" %3d:%3d", run, level);
+#endif
+ if (cpb == &bi->pb && size > dv_bits_left(bi)) {
+ size -= dv_bits_left(bi);
+ put_bits(cpb, dv_bits_left(bi), vlc >> size);
+ vlc = vlc & ((1<<size)-1);
+ cpb = heap;
+ }
+ put_bits(cpb, size, vlc);
+ run = 0;
+ } else
+ run++;
}
- /* NOTE: we only accept several full frames */
- if (buf_size < packet_size)
- return -1;
-
- /* NTSC[dsf == 0] is always 720x480, 4:1:1
- * PAL[dsf == 1] is always 720x576, 4:2:0 for IEC 68134[apt == 0]
- * but for the SMPTE 314M[apt == 1] it is 720x576, 4:1:1
- */
- s->sampling_411 = !dsf || apt;
- if (s->sampling_411) {
- mb_pos_ptr = dsf ? dv_place_411P : dv_place_411;
- avctx->pix_fmt = PIX_FMT_YUV411P;
- } else {
- mb_pos_ptr = dv_place_420;
- avctx->pix_fmt = PIX_FMT_YUV420P;
+
+ if (i == 64) {
+ size = 4; vlc = 6; /* End Of Block stamp */
+ goto put_vlc;
}
+}
- avctx->width = width;
- avctx->height = height;
+static inline void dv_redistr_bits(EncBlockInfo* bi, int count, uint8_t* extra_data, int extra_bits, PutBitContext* heap)
+{
+ int i;
+ GetBitContext gb;
- /* Once again, this is pretty complicated by the fact that the same
- * field is used differently by IEC 68134[apt == 0] and
- * SMPTE 314M[apt == 1].
- */
- if (buf[VAUX_TC61_OFFSET] == 0x61 &&
- ((apt == 0 && (buf[VAUX_TC61_OFFSET + 2] & 0x07) == 0x07) ||
- (apt == 1 && (buf[VAUX_TC61_OFFSET + 2] & 0x07) == 0x02)))
- avctx->aspect_ratio = 16.0 / 9.0;
- else
- avctx->aspect_ratio = 4.0 / 3.0;
-
- if(s->picture.data[0])
- avctx->release_buffer(avctx, &s->picture);
+ init_get_bits(&gb, extra_data, extra_bits);
- s->picture.reference= 0;
- if(avctx->get_buffer(avctx, &s->picture) < 0) {
- fprintf(stderr, "get_buffer() failed\n");
- return -1;
+ for (i=0; i<count; i++) {
+ int bits_left = dv_bits_left(bi);
+#ifdef VLC_DEBUG
+ if (bits_left)
+ printf("------------> inserting %d bytes in %d:%d\n", bits_left, i/6, i%6);
+#endif
+ if (bits_left > extra_bits) {
+ bit_copy(&bi->pb, &gb, extra_bits);
+ extra_bits = 0;
+ break;
+ } else
+ bit_copy(&bi->pb, &gb, bits_left);
+
+ extra_bits -= bits_left;
+ bi++;
}
+
+ if (extra_bits > 0 && heap)
+ bit_copy(heap, &gb, extra_bits);
+}
- for(i=0;i<3;i++) {
- s->current_picture[i] = s->picture.data[i];
- s->linesize[i] = s->picture.linesize[i];
- if (!s->current_picture[i])
- return -1;
- }
- s->width = width;
- s->height = height;
+static inline void dv_set_class_number(EncBlockInfo* bi, int j)
+{
+ int i, max_ac = 0;
- /* for each DIF segment */
- buf_ptr = buf;
- for (ds = 0; ds < nb_dif_segs; ds++) {
- buf_ptr += 6 * 80; /* skip DIF segment header */
-
- for(vs = 0; vs < 27; vs++) {
- if ((vs % 3) == 0) {
- /* skip audio block */
- buf_ptr += 80;
- }
- dv_decode_video_segment(s, buf_ptr, mb_pos_ptr);
- buf_ptr += 5 * 80;
- mb_pos_ptr += 5;
- }
+ for (i=1; i<64; i++) {
+ int ac = abs(bi->mb[ff_zigzag_direct[i]]) / 4;
+ if (max_ac < ac)
+ max_ac = ac;
}
-
- emms_c();
-
- /* return image */
- *data_size = sizeof(AVFrame);
- *(AVFrame*)data= s->picture;
+ if (max_ac < 12)
+ bi->cno = j;
+ else if (max_ac < 24)
+ bi->cno = j + 1;
+ else if (max_ac < 36)
+ bi->cno = j + 2;
+ else
+ bi->cno = j + 3;
- return packet_size;
+ if (bi->cno > 3)
+ bi->cno = 3;
}
-static int dvvideo_decode_end(AVCodecContext *avctx)
+/*
+ * This is a very rough initial implementaion. The performance is
+ * horrible and some features are missing, mainly 2-4-8 DCT encoding.
+ * The weighting is missing as well, but it's missing from the decoding
+ * step also -- so at least we're on the same page with decoder ;-)
+ */
+static inline void dv_encode_video_segment(DVVideoDecodeContext *s,
+ uint8_t *dif,
+ const uint16_t *mb_pos_ptr)
{
- DVVideoDecodeContext *s = avctx->priv_data;
-
- avcodec_default_free_buffers(avctx);
+ int mb_index, i, j, v;
+ int mb_x, mb_y, c_offset, linesize;
+ uint8_t* y_ptr;
+ uint8_t* data;
+ int do_edge_wrap;
+ DCTELEM *block;
+ EncBlockInfo enc_blks[5*6];
+ EncBlockInfo* enc_blk;
+ int free_vs_bits;
+ int extra_bits;
+ PutBitContext extra_vs;
+ uint8_t extra_vs_data[5*6*128];
+ uint8_t extra_mb_data[6*128];
+
+ int QNO = 15;
+
+ /* Stage 1 -- doing DCT on 5 MBs */
+ block = &s->block[0][0];
+ for(mb_index = 0; mb_index < 5; mb_index++) {
+ v = *mb_pos_ptr++;
+ mb_x = v & 0xff;
+ mb_y = v >> 8;
+ y_ptr = s->picture.data[0] + (mb_y * s->picture.linesize[0] * 8) + (mb_x * 8);
+ c_offset = (s->sys->pix_fmt == PIX_FMT_YUV411P) ?
+ ((mb_y * s->picture.linesize[1] * 8) + ((mb_x >> 2) * 8)) :
+ (((mb_y >> 1) * s->picture.linesize[1] * 8) + ((mb_x >> 1) * 8));
+ do_edge_wrap = 0;
+ for(j = 0;j < 6; j++) {
+ if (j < 4) { /* Four Y blocks */
+ /* NOTE: at end of line, the macroblock is handled as 420 */
+ if (s->sys->pix_fmt == PIX_FMT_YUV411P && mb_x < (704 / 8)) {
+ data = y_ptr + (j * 8);
+ } else {
+ data = y_ptr + ((j & 1) * 8) + ((j >> 1) * 8 * s->picture.linesize[0]);
+ }
+ linesize = s->picture.linesize[0];
+ } else { /* Cr and Cb blocks */
+ /* don't ask Fabrice why they inverted Cb and Cr ! */
+ data = s->picture.data[6 - j] + c_offset;
+ linesize = s->picture.linesize[6 - j];
+ if (s->sys->pix_fmt == PIX_FMT_YUV411P && mb_x >= (704 / 8))
+ do_edge_wrap = 1;
+ }
+
+ /* Everything is set up -- now just copy data -> DCT block */
+ if (do_edge_wrap) { /* Edge wrap copy: 4x16 -> 8x8 */
+ uint8_t* d;
+ DCTELEM *b = block;
+ for (i=0;i<8;i++) {
+ d = data + 8 * linesize;
+ b[0] = data[0]; b[1] = data[1]; b[2] = data[2]; b[3] = data[3];
+ b[4] = d[0]; b[5] = d[1]; b[6] = d[2]; b[7] = d[3];
+ data += linesize;
+ b += 8;
+ }
+ } else { /* Simple copy: 8x8 -> 8x8 */
+ s->get_pixels(block, data, linesize);
+ }
+
+ s->fdct(block);
+
+ block += 64;
+ }
+ }
- return 0;
-}
+ /* Stage 2 -- setup for encoding phase */
+ enc_blk = &enc_blks[0];
+ block = &s->block[0][0];
+ for (i=0; i<5; i++) {
+ for (j=0; j<6; j++) {
+ enc_blk->mb = block;
+ enc_blk->dct_mode = 0;
+ enc_blk->block_size = block_sizes[j];
+
+ dv_set_class_number(enc_blk, j/4*(j%2));
+
+ block += 64;
+ enc_blk++;
+ }
+ }
+
+ /* Stage 3 -- encoding by trial-and-error */
+encode_vs:
+ enc_blk = &enc_blks[0];
+ for (i=0; i<5; i++) {
+ uint8_t* p = dif + i*80 + 4;
+ for (j=0; j<6; j++) {
+ enc_blk->qno = QNO;
+ init_put_bits(&enc_blk->pb, p, block_sizes[j]/8);
+ enc_blk++;
+ p += block_sizes[j]/8;
+ }
+ }
-AVCodec dvvideo_decoder = {
- "dvvideo",
- CODEC_TYPE_VIDEO,
- CODEC_ID_DVVIDEO,
- sizeof(DVVideoDecodeContext),
- dvvideo_decode_init,
- NULL,
- dvvideo_decode_end,
- dvvideo_decode_frame,
- CODEC_CAP_DR1,
- NULL
-};
+ init_put_bits(&extra_vs, extra_vs_data, sizeof(extra_vs_data));
+ free_vs_bits = 0;
+ enc_blk = &enc_blks[0];
+ for (i=0; i<5; i++) {
+ PutBitContext extra_mb;
+ EncBlockInfo* enc_blk2 = enc_blk;
+ int free_mb_bits = 0;
-typedef struct DVAudioDecodeContext {
- AVCodecContext *avctx;
- GetBitContext gb;
-} DVAudioDecodeContext;
+ init_put_bits(&extra_mb, extra_mb_data, sizeof(extra_mb_data));
+ dif[i*80 + 3] = enc_blk->qno;
+
+ for (j=0; j<6; j++) {
+ uint16_t dc = ((enc_blk->mb[0] >> 3) - 1024) >> 2;
-static int dvaudio_decode_init(AVCodecContext *avctx)
-{
- // DVAudioDecodeContext *s = avctx->priv_data;
- return 0;
-}
+ put_bits(&enc_blk->pb, 9, dc);
+ put_bits(&enc_blk->pb, 1, enc_blk->dct_mode);
+ put_bits(&enc_blk->pb, 2, enc_blk->cno);
-static uint16_t dv_audio_12to16(uint16_t sample)
-{
- uint16_t shift, result;
+#ifdef VLC_DEBUG
+ printf("[%d, %d]: ", i, j);
+#endif
+ dv_encode_ac(enc_blk, &extra_mb);
+#ifdef VLC_DEBUG
+ printf("\n");
+#endif
+
+ free_mb_bits += dv_bits_left(enc_blk);
+ enc_blk++;
+ }
+
+ /* We can't flush extra_mb just yet -- since it'll round up bit number */
+ extra_bits = get_bit_count(&extra_mb);
+ if (free_mb_bits > extra_bits)
+ free_vs_bits += free_mb_bits - extra_bits;
- sample = (sample < 0x800) ? sample : sample | 0xf000;
- shift = (sample & 0xf00) >> 8;
-
- if (shift < 0x2 || shift > 0xd) {
- result = sample;
- } else if (shift < 0x8) {
- shift--;
- result = (sample - (256 * shift)) << shift;
- } else {
- shift = 0xe - shift;
- result = ((sample + ((256 * shift) + 1)) << shift) - 1;
+ if (extra_bits) { /* FIXME: speed up things when free_mb_bits == 0 */
+ flush_put_bits(&extra_mb);
+ dv_redistr_bits(enc_blk2, 6, extra_mb_data, extra_bits, &extra_vs);
+ }
+ }
+
+ /* We can't flush extra_mb just yet -- since it'll round up bit number */
+ extra_bits = get_bit_count(&extra_vs);
+ if (extra_bits > free_vs_bits && QNO) { /* FIXME: very crude trial-and-error */
+ QNO--;
+ goto encode_vs;
+ }
+
+ if (extra_bits) {
+ flush_put_bits(&extra_vs);
+ dv_redistr_bits(&enc_blks[0], 5*6, extra_vs_data, extra_bits, NULL);
}
- return result;
+ for (i=0; i<6*5; i++) {
+ flush_put_bits(&enc_blks[i].pb);
+#ifdef VLC_DEBUG
+ printf("[%d:%d] qno=%d cno=%d\n", i/6, i%6, enc_blks[i].qno, enc_blks[i].cno);
+#endif
+ }
}
/* NOTE: exactly one frame must be given (120000 bytes for NTSC,
- 144000 bytes for PAL)
-
- There's a couple of assumptions being made here:
- 1. By default we silence erroneous (0x8000/16bit 0x800/12bit)
- audio samples. We can pass them upwards when ffmpeg will be ready
- to deal with them.
- 2. We don't do software emphasis.
- 3. Audio is always returned as 16bit linear samples: 12bit
- nonlinear samples are converted into 16bit linear ones.
-*/
-static int dvaudio_decode_frame(AVCodecContext *avctx,
+ 144000 bytes for PAL) */
+static int dvvideo_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
DVVideoDecodeContext *s = avctx->priv_data;
- const uint16_t (*unshuffle)[9];
- int smpls, freq, quant, sys, stride, difseg, ad, dp, nb_dif_segs, i;
- uint16_t lc, rc;
- uint8_t *buf_ptr;
+ int ds, vs;
+ const uint16_t *mb_pos_ptr;
- /* parse id */
- init_get_bits(&s->gb, &buf[AAUX_AS_OFFSET], 5*8);
- i = get_bits(&s->gb, 8);
- if (i != 0x50) { /* No audio ? */
- *data_size = 0;
- return buf_size;
- }
+ s->sys = dv_frame_profile(buf);
+ if (!s->sys || buf_size < s->sys->frame_size)
+ return -1; /* NOTE: we only accept several full frames */
+
+
+ if(s->picture.data[0])
+ avctx->release_buffer(avctx, &s->picture);
- get_bits(&s->gb, 1); /* 0 - locked audio, 1 - unlocked audio */
- skip_bits(&s->gb, 1);
- smpls = get_bits(&s->gb, 6); /* samples in this frame - min. samples */
+ s->picture.reference = 0;
+ avctx->pix_fmt = s->sys->pix_fmt;
+ avctx->width = s->sys->width;
+ avctx->height = s->sys->height;
+ if(avctx->get_buffer(avctx, &s->picture) < 0) {
+ fprintf(stderr, "get_buffer() failed\n");
+ return -1;
+ }
+ s->picture.interlaced_frame = 1;
+ s->picture.top_field_first = 0;
- skip_bits(&s->gb, 8);
+ /* for each DIF segment */
+ mb_pos_ptr = s->sys->video_place;
+ for (ds = 0; ds < s->sys->difseg_size; ds++) {
+ buf += 6 * 80; /* skip DIF segment header */
+
+ for(vs = 0; vs < 27; vs++) {
+ if ((vs % 3) == 0)
+ buf += 80; /* skip audio block */
+
+#ifdef VLC_DEBUG
+ printf("********************* %d, %d **********************\n", ds, vs);
+#endif
+ dv_decode_video_segment(s, buf, mb_pos_ptr);
+ buf += 5 * 80;
+ mb_pos_ptr += 5;
+ }
+ }
- skip_bits(&s->gb, 2);
- sys = get_bits(&s->gb, 1); /* 0 - 60 fields, 1 = 50 fields */
- skip_bits(&s->gb, 5);
+ emms_c();
- get_bits(&s->gb, 1); /* 0 - emphasis on, 1 - emphasis off */
- get_bits(&s->gb, 1); /* 0 - reserved, 1 - emphasis time constant 50/15us */
- freq = get_bits(&s->gb, 3); /* 0 - 48KHz, 1 - 44,1kHz, 2 - 32 kHz */
- quant = get_bits(&s->gb, 3); /* 0 - 16bit linear, 1 - 12bit nonlinear */
+ /* return image */
+ *data_size = sizeof(AVFrame);
+ *(AVFrame*)data= s->picture;
+
+ return s->sys->frame_size;
+}
- if (quant > 1)
- return -1; /* Unsupported quantization */
+static int dvvideo_encode_frame(AVCodecContext *c, uint8_t *buf, int buf_size,
+ void *data)
+{
+ DVVideoDecodeContext *s = c->priv_data;
+ const uint16_t *mb_pos_ptr;
+ int ds, vs;
- avctx->sample_rate = dv_audio_frequency[freq];
- avctx->channels = 2;
- avctx->bit_rate = avctx->channels * avctx->sample_rate * 16;
- // What about:
- // avctx->frame_size =
-
- *data_size = (dv_audio_min_samples[sys][freq] + smpls) *
- avctx->channels * 2;
-
- if (sys) {
- nb_dif_segs = 12;
- stride = 108;
- unshuffle = dv_place_audio50;
- } else {
- nb_dif_segs = 10;
- stride = 90;
- unshuffle = dv_place_audio60;
- }
+ s->sys = dv_codec_profile(c);
+ if (!s->sys)
+ return -1;
+ c->pix_fmt = s->sys->pix_fmt;
+ s->picture = *((AVFrame *)data);
+
/* for each DIF segment */
- buf_ptr = buf;
- for (difseg = 0; difseg < nb_dif_segs; difseg++) {
- buf_ptr += 6 * 80; /* skip DIF segment header */
- for (ad = 0; ad < 9; ad++) {
-
- for (dp = 8; dp < 80; dp+=2) {
- if (quant == 0) { /* 16bit quantization */
- i = unshuffle[difseg][ad] + (dp - 8)/2 * stride;
- ((short *)data)[i] = (buf_ptr[dp] << 8) | buf_ptr[dp+1];
- if (((unsigned short *)data)[i] == 0x8000)
- ((short *)data)[i] = 0;
- } else { /* 12bit quantization */
- if (difseg >= nb_dif_segs/2)
- goto out; /* We're not doing 4ch at this time */
-
- lc = ((uint16_t)buf_ptr[dp] << 4) |
- ((uint16_t)buf_ptr[dp+2] >> 4);
- rc = ((uint16_t)buf_ptr[dp+1] << 4) |
- ((uint16_t)buf_ptr[dp+2] & 0x0f);
- lc = (lc == 0x800 ? 0 : dv_audio_12to16(lc));
- rc = (rc == 0x800 ? 0 : dv_audio_12to16(rc));
-
- i = unshuffle[difseg][ad] + (dp - 8)/3 * stride;
- ((short *)data)[i] = lc;
- i = unshuffle[difseg+nb_dif_segs/2][ad] + (dp - 8)/3 * stride;
- ((short *)data)[i] = rc;
- ++dp;
- }
- }
-
- buf_ptr += 16 * 80; /* 15 Video DIFs + 1 Audio DIF */
+ mb_pos_ptr = s->sys->video_place;
+ for (ds = 0; ds < s->sys->difseg_size; ds++) {
+ buf += 6 * 80; /* skip DIF segment header */
+
+ for(vs = 0; vs < 27; vs++) {
+ if ((vs % 3) == 0)
+ buf += 80; /* skip audio block */
+
+#ifdef VLC_DEBUG
+ printf("********************* %d, %d **********************\n", ds, vs);
+#endif
+ dv_encode_video_segment(s, buf, mb_pos_ptr);
+ buf += 5 * 80;
+ mb_pos_ptr += 5;
}
}
-out:
- return buf_size;
+ emms_c();
+ return s->sys->frame_size;
}
-static int dvaudio_decode_end(AVCodecContext *avctx)
+static int dvvideo_end(AVCodecContext *avctx)
{
- // DVAudioDecodeContext *s = avctx->priv_data;
+ avcodec_default_free_buffers(avctx);
return 0;
}
-AVCodec dvaudio_decoder = {
- "dvaudio",
- CODEC_TYPE_AUDIO,
- CODEC_ID_DVAUDIO,
- sizeof(DVAudioDecodeContext),
- dvaudio_decode_init,
- NULL,
- dvaudio_decode_end,
- dvaudio_decode_frame,
- 0,
+AVCodec dvvideo_decoder = {
+ "dvvideo",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_DVVIDEO,
+ sizeof(DVVideoDecodeContext),
+ dvvideo_init,
+ dvvideo_encode_frame,
+ dvvideo_end,
+ dvvideo_decode_frame,
+ CODEC_CAP_DR1,
NULL
};
diff --git a/src/libffmpeg/libavcodec/dvdata.h b/src/libffmpeg/libavcodec/dvdata.h
index bab69133e..16b5786a8 100644
--- a/src/libffmpeg/libavcodec/dvdata.h
+++ b/src/libffmpeg/libavcodec/dvdata.h
@@ -21,11 +21,34 @@
* @file dvdata.h
* Constants for DV codec.
*/
-
+
+/*
+ * DVprofile is used to express the differences between various
+ * DV flavors. For now it's primarily used for differentiating
+ * 525/60 and 625/50, but the plans are to use it for various
+ * DV specs as well (e.g. SMPTE314M vs. IEC 61834).
+ */
+typedef struct DVprofile {
+ int dsf; /* value of the dsf in the DV header */
+ int frame_size; /* total size of one frame in bytes */
+ int difseg_size; /* number of DIF segments */
+ int frame_rate;
+ int frame_rate_base;
+ int ltc_divisor; /* FPS from the LTS standpoint */
+ int height; /* picture height in pixels */
+ int width; /* picture width in pixels */
+ const uint16_t *video_place; /* positions of all DV macro blocks */
+ enum PixelFormat pix_fmt; /* picture pixel format */
+
+ int audio_stride; /* size of audio_shuffle table */
+ int audio_min_samples[3];/* min ammount of audio samples */
+ /* for 48Khz, 44.1Khz and 32Khz */
+ int audio_samples_dist[5];/* how many samples are supposed to be */
+ /* in each frame in a 5 frames window */
+ const uint16_t (*audio_shuffle)[9]; /* PCM shuffling table */
+} DVprofile;
+
#define NB_DV_VLC 409
-#define AAUX_AS_OFFSET (80*6 + 80*16*3 + 3)
-#define AAUX_ASC_OFFSET (80*6 + 80*16*4 + 3)
-#define VAUX_TC61_OFFSET (80*5 + 48 + 5)
static const uint16_t dv_vlc_bits[409] = {
0x0000, 0x0002, 0x0007, 0x0008, 0x0009, 0x0014, 0x0015, 0x0016,
@@ -283,7 +306,7 @@ static const uint8_t dv_248_areas[64] = {
1,2,2,3,3,3,3,3,
};
-static uint8_t dv_quant_shifts[22][4] = {
+static const uint8_t dv_quant_shifts[22][4] = {
{ 3,3,4,4 },
{ 3,3,4,4 },
{ 2,3,3,4 },
@@ -1240,7 +1263,7 @@ static const uint16_t dv_place_411[1350] = {
0x0834, 0x2320, 0x2f44, 0x3810, 0x1658,
};
-static const uint16_t dv_place_audio60[10][9] = {
+static const uint16_t dv_audio_shuffle525[10][9] = {
{ 0, 30, 60, 20, 50, 80, 10, 40, 70 }, /* 1st channel */
{ 6, 36, 66, 26, 56, 86, 16, 46, 76 },
{ 12, 42, 72, 2, 32, 62, 22, 52, 82 },
@@ -1254,7 +1277,7 @@ static const uint16_t dv_place_audio60[10][9] = {
{ 25, 55, 85, 15, 45, 75, 5, 35, 65 },
};
-static const uint16_t dv_place_audio50[12][9] = {
+static const uint16_t dv_audio_shuffle625[12][9] = {
{ 0, 36, 72, 26, 62, 98, 16, 52, 88}, /* 1st channel */
{ 6, 42, 78, 32, 68, 104, 22, 58, 94},
{ 12, 48, 84, 2, 38, 74, 28, 64, 100},
@@ -1270,11 +1293,78 @@ static const uint16_t dv_place_audio50[12][9] = {
{ 31, 67, 103, 21, 57, 93, 11, 47, 83},
};
-static const int dv_audio_frequency[3] = {
- 48000, 44100, 32000,
+static const __attribute__((unused)) int dv_audio_frequency[3] = {
+ 48000, 44100, 32000,
};
-
-static const int dv_audio_min_samples[2][3] = {
- { 1580, 1452, 1053 }, /* 60 fields */
- { 1896, 1742, 1264 }, /* 50 fileds */
+
+static const DVprofile dv_profiles[] = {
+ { .dsf = 0,
+ .frame_size = 120000, /* IEC 61834, SMPTE-314M - 525/60 (NTSC) */
+ .difseg_size = 10,
+ .frame_rate = 30000,
+ .ltc_divisor = 30,
+ .frame_rate_base = 1001,
+ .height = 480,
+ .width = 720,
+ .video_place = dv_place_411,
+ .pix_fmt = PIX_FMT_YUV411P,
+ .audio_stride = 90,
+ .audio_min_samples = { 1580, 1452, 1053 }, /* for 48, 44.1 and 32Khz */
+ .audio_samples_dist = { 1602, 1601, 1602, 1601, 1602 },
+ .audio_shuffle = dv_audio_shuffle525,
+ },
+ { .dsf = 1,
+ .frame_size = 144000, /* IEC 61834 - 625/50 (PAL) */
+ .difseg_size = 12,
+ .frame_rate = 25,
+ .frame_rate_base = 1,
+ .ltc_divisor = 25,
+ .height = 576,
+ .width = 720,
+ .video_place = dv_place_420,
+ .pix_fmt = PIX_FMT_YUV420P,
+ .audio_stride = 108,
+ .audio_min_samples = { 1896, 1742, 1264 }, /* for 48, 44.1 and 32Khz */
+ .audio_samples_dist = { 1920, 1920, 1920, 1920, 1920 },
+ .audio_shuffle = dv_audio_shuffle625,
+ },
+ { .dsf = 1,
+ .frame_size = 144000, /* SMPTE-314M - 625/50 (PAL) */
+ .difseg_size = 12,
+ .frame_rate = 25,
+ .frame_rate_base = 1,
+ .ltc_divisor = 25,
+ .height = 576,
+ .width = 720,
+ .video_place = dv_place_411P,
+ .pix_fmt = PIX_FMT_YUV411P,
+ .audio_stride = 108,
+ .audio_min_samples = { 1896, 1742, 1264 }, /* for 48, 44.1 and 32Khz */
+ .audio_samples_dist = { 1920, 1920, 1920, 1920, 1920 },
+ .audio_shuffle = dv_audio_shuffle625,
+ }
};
+
+static inline const DVprofile* dv_frame_profile(uint8_t* frame)
+{
+ if ((frame[3] & 0x80) == 0) { /* DSF flag */
+ return &dv_profiles[0];
+ }
+ else if ((frame[5] & 0x07) == 0) { /* APT flag */
+ return &dv_profiles[1];
+ }
+ else
+ return &dv_profiles[2];
+}
+
+static inline const DVprofile* dv_codec_profile(AVCodecContext* codec)
+{
+ if (codec->width != 720) {
+ return NULL;
+ }
+ else if (codec->height == 480) {
+ return &dv_profiles[0];
+ }
+ else
+ return &dv_profiles[1];
+}
diff --git a/src/libffmpeg/libavcodec/error_resilience.c b/src/libffmpeg/libavcodec/error_resilience.c
index 4ac92bfd2..5ac2190b3 100644
--- a/src/libffmpeg/libavcodec/error_resilience.c
+++ b/src/libffmpeg/libavcodec/error_resilience.c
@@ -30,6 +30,14 @@
#include "mpegvideo.h"
#include "common.h"
+static void decode_mb(MpegEncContext *s){
+ s->dest[0] = s->current_picture.data[0] + (s->mb_y * 16* s->linesize ) + s->mb_x * 16;
+ s->dest[1] = s->current_picture.data[1] + (s->mb_y * 8 * s->uvlinesize) + s->mb_x * 8;
+ s->dest[2] = s->current_picture.data[2] + (s->mb_y * 8 * s->uvlinesize) + s->mb_x * 8;
+
+ MPV_decode_mb(s, s->block);
+}
+
/**
* replaces the current MB with a flat dc only version.
*/
@@ -346,7 +354,7 @@ static void guess_mv(MpegEncContext *s){
s->mb_y= mb_y;
s->mv[0][0][0]= 0;
s->mv[0][0][1]= 0;
- MPV_decode_mb(s, s->block);
+ decode_mb(s);
}
}
return;
@@ -480,7 +488,7 @@ int score_sum=0;
s->motion_val[mot_index][0]= s->mv[0][0][0]= mv_predictor[j][0];
s->motion_val[mot_index][1]= s->mv[0][0][1]= mv_predictor[j][1];
- MPV_decode_mb(s, s->block);
+ decode_mb(s);
if(mb_x>0 && fixed[mb_xy-1]){
int k;
@@ -513,7 +521,7 @@ score_sum+= best_score;
s->motion_val[mot_index][0]= s->mv[0][0][0]= mv_predictor[best_pred][0];
s->motion_val[mot_index][1]= s->mv[0][0][1]= mv_predictor[best_pred][1];
- MPV_decode_mb(s, s->block);
+ decode_mb(s);
if(s->mv[0][0][0] != prev_x || s->mv[0][0][1] != prev_y){
@@ -848,7 +856,7 @@ void ff_er_frame_end(MpegEncContext *s){
s->mb_x= mb_x;
s->mb_y= mb_y;
- MPV_decode_mb(s, s->block);
+ decode_mb(s);
}
}
@@ -888,12 +896,16 @@ void ff_er_frame_end(MpegEncContext *s){
s->dsp.clear_blocks(s->block[0]);
s->mb_x= mb_x;
s->mb_y= mb_y;
- MPV_decode_mb(s, s->block);
+ decode_mb(s);
}
}
}else
guess_mv(s);
+#ifdef HAVE_XVMC
+ /* the filters below are not XvMC compatible, skip them */
+ if(s->avctx->xvmc_acceleration) goto ec_clean;
+#endif
/* fill DC for inter blocks */
for(mb_y=0; mb_y<s->mb_height; mb_y++){
for(mb_x=0; mb_x<s->mb_width; mb_x++){
@@ -979,6 +991,9 @@ void ff_er_frame_end(MpegEncContext *s){
v_block_filter(s, s->current_picture.data[2], s->mb_width , s->mb_height , s->uvlinesize, 0);
}
+#ifdef HAVE_XVMC
+ec_clean:
+#endif
/* clean a few tables */
for(i=0; i<s->mb_num; i++){
const int mb_xy= s->mb_index2xy[i];
diff --git a/src/libffmpeg/libavcodec/golomb.h b/src/libffmpeg/libavcodec/golomb.h
index 9861b18d1..5ebebe94c 100644
--- a/src/libffmpeg/libavcodec/golomb.h
+++ b/src/libffmpeg/libavcodec/golomb.h
@@ -179,7 +179,7 @@ static inline int svq3_get_se_golomb(GetBitContext *gb){
}
/**
- * read unsigned golomb rice code.
+ * read unsigned golomb rice code (ffv1).
*/
static inline int get_ur_golomb(GetBitContext *gb, int k, int limit, int esc_len){
unsigned int buf;
@@ -190,7 +190,7 @@ static inline int get_ur_golomb(GetBitContext *gb, int k, int limit, int esc_len
buf=GET_CACHE(re, gb);
log= av_log2(buf);
-//printf("buf:%X log:%d\n", buf, log);
+
if(log > 31-limit){
buf >>= log - k;
buf += (30-log)<<k;
@@ -198,15 +198,62 @@ static inline int get_ur_golomb(GetBitContext *gb, int k, int limit, int esc_len
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);
+ }else{
+ buf >>= 32 - limit - esc_len;
+ LAST_SKIP_BITS(re, gb, esc_len + limit);
CLOSE_READER(re, gb);
- return buf + 1;
- }else
- return -1;
+ return buf + limit - 1;
+ }
+}
+
+/**
+ * read unsigned golomb rice code (jpegls).
+ */
+static inline int get_ur_golomb_jpegls(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);
+
+ log= av_log2(buf);
+
+ if(log > 31-11){
+ buf >>= log - k;
+ buf += (30-log)<<k;
+ LAST_SKIP_BITS(re, gb, 32 + k - log);
+ CLOSE_READER(re, gb);
+
+ return buf;
+ }else{
+ int i;
+ for(i=0; SHOW_UBITS(re, gb, 1) == 0; i++){
+ LAST_SKIP_BITS(re, gb, 1);
+ UPDATE_CACHE(re, gb);
+ }
+ SKIP_BITS(re, gb, 1);
+
+ if(i < limit - 1){
+ if(k){
+ buf = SHOW_UBITS(re, gb, k);
+ LAST_SKIP_BITS(re, gb, k);
+ }else{
+ buf=0;
+ }
+
+ CLOSE_READER(re, gb);
+ return buf + (i<<k);
+ }else if(i == limit - 1){
+ buf = SHOW_UBITS(re, gb, esc_len);
+ LAST_SKIP_BITS(re, gb, esc_len);
+ CLOSE_READER(re, gb);
+
+ return buf + 1;
+ }else
+ return -1;
+ }
}
#ifdef TRACE
@@ -312,7 +359,7 @@ static inline void set_se_golomb(PutBitContext *pb, int i){
}
/**
- * write unsigned golomb rice code.
+ * write unsigned golomb rice code (ffv1).
*/
static inline void set_ur_golomb(PutBitContext *pb, int i, int k, int limit, int esc_len){
int e;
@@ -323,9 +370,25 @@ static inline void set_ur_golomb(PutBitContext *pb, int i, int k, int limit, int
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);
+ put_bits(pb, limit + esc_len, i - limit + 1);
+ }
+}
+
+/**
+ * write unsigned golomb rice code (jpegls).
+ */
+static inline void set_ur_golomb_jpegls(PutBitContext *pb, int i, int k, int limit, int esc_len){
+ int e;
+
+ assert(i>=0);
+
+ e= (i>>k) + 1;
+ if(e<limit){
+ put_bits(pb, e, 1);
+ if(k)
+ put_bits(pb, k, i&((1<<k)-1));
+ }else{
+ put_bits(pb, limit , 1);
+ put_bits(pb, esc_len, i - 1);
}
}
diff --git a/src/libffmpeg/libavcodec/h263.c b/src/libffmpeg/libavcodec/h263.c
index 7fe89f7bc..0b09dc731 100644
--- a/src/libffmpeg/libavcodec/h263.c
+++ b/src/libffmpeg/libavcodec/h263.c
@@ -29,6 +29,8 @@
*/
//#define DEBUG
+#include <limits.h>
+
#include "common.h"
#include "dsputil.h"
#include "avcodec.h"
@@ -40,7 +42,7 @@
//#include <assert.h>
#define INTRA_MCBPC_VLC_BITS 6
-#define INTER_MCBPC_VLC_BITS 6
+#define INTER_MCBPC_VLC_BITS 7
#define CBPY_VLC_BITS 6
#define MV_VLC_BITS 9
#define DC_VLC_BITS 9
@@ -50,11 +52,11 @@
#ifdef CONFIG_ENCODERS
static void h263_encode_block(MpegEncContext * s, DCTELEM * block,
- int n);
+ int n);
static void h263_encode_motion(MpegEncContext * s, int val, int fcode);
static void h263p_encode_umotion(MpegEncContext * s, int val);
static inline void mpeg4_encode_block(MpegEncContext * s, DCTELEM * block,
- int n, int dc, uint8_t *scan_table,
+ int n, int dc, uint8_t *scan_table,
PutBitContext *dc_pb, PutBitContext *ac_pb);
#endif
@@ -67,8 +69,8 @@ static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
int n, int coded, int intra, int rvlc);
static int h263_pred_dc(MpegEncContext * s, int n, uint16_t **dc_val_ptr);
#ifdef CONFIG_ENCODERS
-static void mpeg4_inv_pred_ac(MpegEncContext * s, DCTELEM *block, int n,
- int dir);
+static void mpeg4_encode_visual_object_header(MpegEncContext * s);
+static void mpeg4_encode_vol_header(MpegEncContext * s, int vo_number, int vol_number);
#endif //CONFIG_ENCODERS
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);
@@ -129,19 +131,13 @@ int h263_get_picture_format(int width, int height)
#ifdef CONFIG_ENCODERS
-static void float_aspect_to_info(MpegEncContext * s, float aspect){
+static void aspect_to_info(MpegEncContext * s, AVRational aspect){
int i;
- aspect*= s->height/(double)s->width;
-//printf("%f\n", aspect);
-
- if(aspect==0) aspect= 1.0;
-
- ff_float2fraction(&s->aspected_width, &s->aspected_height, aspect, 255);
+ if(aspect.num==0) aspect= (AVRational){1,1};
-//printf("%d %d\n", s->aspected_width, s->aspected_height);
for(i=1; i<6; i++){
- if(s->aspected_width == pixel_aspect[i][0] && s->aspected_height== pixel_aspect[i][1]){
+ if(av_cmp_q(pixel_aspect[i], aspect) == 0){
s->aspect_ratio_info=i;
return;
}
@@ -150,6 +146,52 @@ static void float_aspect_to_info(MpegEncContext * s, float aspect){
s->aspect_ratio_info= FF_ASPECT_EXTENDED;
}
+void ff_flv_encode_picture_header(MpegEncContext * s, int picture_number)
+{
+ int format;
+
+ align_put_bits(&s->pb);
+
+ put_bits(&s->pb, 17, 1);
+ put_bits(&s->pb, 5, (s->h263_flv-1)); /* 0: h263 escape codes 1: 11-bit escape codes */
+ put_bits(&s->pb, 8, (((int64_t)s->picture_number * 30 * s->avctx->frame_rate_base) /
+ s->avctx->frame_rate) & 0xff); /* TemporalReference */
+ if (s->width == 352 && s->height == 288)
+ format = 2;
+ else if (s->width == 176 && s->height == 144)
+ format = 3;
+ else if (s->width == 128 && s->height == 96)
+ format = 4;
+ else if (s->width == 320 && s->height == 240)
+ format = 5;
+ else if (s->width == 160 && s->height == 120)
+ format = 6;
+ else if (s->width <= 255 && s->height <= 255)
+ format = 0; /* use 1 byte width & height */
+ else
+ format = 1; /* use 2 bytes width & height */
+ put_bits(&s->pb, 3, format); /* PictureSize */
+ if (format == 0) {
+ put_bits(&s->pb, 8, s->width);
+ put_bits(&s->pb, 8, s->height);
+ } else if (format == 1) {
+ put_bits(&s->pb, 16, s->width);
+ put_bits(&s->pb, 16, s->height);
+ }
+ put_bits(&s->pb, 2, s->pict_type == P_TYPE); /* PictureType */
+ put_bits(&s->pb, 1, 1); /* DeblockingFlag: on */
+ put_bits(&s->pb, 5, s->qscale); /* Quantizer */
+ put_bits(&s->pb, 1, 0); /* ExtraInformation */
+
+ if(s->h263_aic){
+ s->y_dc_scale_table=
+ s->c_dc_scale_table= h263_aic_dc_scale_table;
+ }else{
+ s->y_dc_scale_table=
+ s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
+ }
+}
+
void h263_encode_picture_header(MpegEncContext * s, int picture_number)
{
int format;
@@ -222,16 +264,15 @@ void h263_encode_picture_header(MpegEncContext * s, int picture_number)
if (format == 7) {
/* Custom Picture Format (CPFMT) */
- float_aspect_to_info(s, s->avctx->aspect_ratio);
+ aspect_to_info(s, s->avctx->sample_aspect_ratio);
put_bits(&s->pb,4,s->aspect_ratio_info);
put_bits(&s->pb,9,(s->width >> 2) - 1);
put_bits(&s->pb,1,1); /* "1" to prevent start code emulation */
put_bits(&s->pb,9,(s->height >> 2));
- if (s->aspect_ratio_info == FF_ASPECT_EXTENDED)
- {
- put_bits(&s->pb, 8, s->aspected_width);
- put_bits(&s->pb, 8, s->aspected_height);
+ if (s->aspect_ratio_info == FF_ASPECT_EXTENDED){
+ put_bits(&s->pb, 8, s->avctx->sample_aspect_ratio.num);
+ put_bits(&s->pb, 8, s->avctx->sample_aspect_ratio.den);
}
}
@@ -275,14 +316,42 @@ int h263_encode_gob_header(MpegEncContext * s, int mb_line)
return 0;
}
-static inline int decide_ac_pred(MpegEncContext * s, DCTELEM block[6][64], int dir[6])
+static inline int get_block_rate(MpegEncContext * s, DCTELEM block[64], int block_last_index, uint8_t scantable[64]){
+ int last=0;
+ int j;
+ int rate=0;
+
+ for(j=1; j<=block_last_index; j++){
+ const int index= scantable[j];
+ int level= block[index];
+ if(level){
+ level+= 64;
+ if((level&(~127)) == 0){
+ if(j<block_last_index) rate+= s->intra_ac_vlc_length [UNI_AC_ENC_INDEX(j-last-1, level)];
+ else rate+= s->intra_ac_vlc_last_length[UNI_AC_ENC_INDEX(j-last-1, level)];
+ }else
+ rate += s->ac_esc_length;
+ level-= 64;
+
+ last= j;
+ }
+ }
+
+ return rate;
+}
+
+static inline int decide_ac_pred(MpegEncContext * s, DCTELEM block[6][64], int dir[6], uint8_t *st[6], int zigzag_last_index[6])
{
- int score0=0, score1=0;
+ int score= 0;
int i, n;
int8_t * const qscale_table= s->current_picture.qscale_table;
+ memcpy(zigzag_last_index, s->block_last_index, sizeof(int)*6);
+
for(n=0; n<6; n++){
int16_t *ac_val, *ac_val1;
+
+ score -= get_block_rate(s, block[n], s->block_last_index[n], s->intra_scantable.permutated);
ac_val = s->ac_val[0][0] + s->block_index[n] * 16;
ac_val1= ac_val;
@@ -294,8 +363,7 @@ static inline int decide_ac_pred(MpegEncContext * s, DCTELEM block[6][64], int d
/* same qscale */
for(i=1; i<8; i++){
const int level= block[n][s->dsp.idct_permutation[i ]];
- score0+= ABS(level);
- score1+= ABS(level - ac_val[i+8]);
+ block[n][s->dsp.idct_permutation[i ]] = level - ac_val[i+8];
ac_val1[i ]= block[n][s->dsp.idct_permutation[i<<3]];
ac_val1[i+8]= level;
}
@@ -303,12 +371,12 @@ static inline int decide_ac_pred(MpegEncContext * s, DCTELEM block[6][64], int d
/* different qscale, we must rescale */
for(i=1; i<8; i++){
const int level= block[n][s->dsp.idct_permutation[i ]];
- score0+= ABS(level);
- score1+= ABS(level - ROUNDED_DIV(ac_val[i + 8]*qscale_table[xy], s->qscale));
+ block[n][s->dsp.idct_permutation[i ]] = level - ROUNDED_DIV(ac_val[i + 8]*qscale_table[xy], s->qscale);
ac_val1[i ]= block[n][s->dsp.idct_permutation[i<<3]];
ac_val1[i+8]= level;
}
}
+ st[n]= s->intra_h_scantable.permutated;
}else{
const int xy= s->mb_x-1 + s->mb_y*s->mb_stride;
/* left prediction */
@@ -317,8 +385,7 @@ static inline int decide_ac_pred(MpegEncContext * s, DCTELEM block[6][64], int d
/* same qscale */
for(i=1; i<8; i++){
const int level= block[n][s->dsp.idct_permutation[i<<3]];
- score0+= ABS(level);
- score1+= ABS(level - ac_val[i]);
+ block[n][s->dsp.idct_permutation[i<<3]]= level - ac_val[i];
ac_val1[i ]= level;
ac_val1[i+8]= block[n][s->dsp.idct_permutation[i ]];
}
@@ -326,16 +393,45 @@ static inline int decide_ac_pred(MpegEncContext * s, DCTELEM block[6][64], int d
/* different qscale, we must rescale */
for(i=1; i<8; i++){
const int level= block[n][s->dsp.idct_permutation[i<<3]];
- score0+= ABS(level);
- score1+= ABS(level - ROUNDED_DIV(ac_val[i]*qscale_table[xy], s->qscale));
+ block[n][s->dsp.idct_permutation[i<<3]]= level - ROUNDED_DIV(ac_val[i]*qscale_table[xy], s->qscale);
ac_val1[i ]= level;
ac_val1[i+8]= block[n][s->dsp.idct_permutation[i ]];
}
}
+ st[n]= s->intra_v_scantable.permutated;
}
+
+ for(i=63; i>0; i--) //FIXME optimize
+ if(block[n][ st[n][i] ]) break;
+ s->block_last_index[n]= i;
+
+ score += get_block_rate(s, block[n], s->block_last_index[n], st[n]);
}
- return score0 > score1 ? 1 : 0;
+ return score < 0;
+}
+
+static inline void restore_ac_coeffs(MpegEncContext * s, DCTELEM block[6][64], int dir[6], uint8_t *st[6], int zigzag_last_index[6])
+{
+ int i, n;
+ memcpy(s->block_last_index, zigzag_last_index, sizeof(int)*6);
+
+ for(n=0; n<6; n++){
+ int16_t *ac_val = s->ac_val[0][0] + s->block_index[n] * 16;
+
+ st[n]= s->intra_scantable.permutated;
+ if(dir[n]){
+ /* top prediction */
+ for(i=1; i<8; i++){
+ block[n][s->dsp.idct_permutation[i ]] = ac_val[i+8];
+ }
+ }else{
+ /* left prediction */
+ for(i=1; i<8; i++){
+ block[n][s->dsp.idct_permutation[i<<3]]= ac_val[i ];
+ }
+ }
+ }
}
/**
@@ -464,13 +560,159 @@ int ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my){
}
}
+void ff_h263_update_motion_val(MpegEncContext * s){
+ const int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
+ //FIXME a lot of thet is only needed for !low_delay
+ const int wrap = s->block_wrap[0];
+ const int xy = s->block_index[0];
+
+ s->current_picture.mbskip_table[mb_xy]= s->mb_skiped;
+
+ if(s->mv_type != MV_TYPE_8X8){
+ int motion_x, motion_y;
+ if (s->mb_intra) {
+ motion_x = 0;
+ 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);
+ for(i=0; i<2; i++){
+ s->field_mv_table[mb_xy][i][0]= s->mv[0][i][0];
+ s->field_mv_table[mb_xy][i][1]= s->mv[0][i][1];
+ s->field_select_table[mb_xy][i]= s->field_select[0][i];
+ }
+ }
+
+ /* no update if 8X8 because it has been done during parsing */
+ s->motion_val[xy][0] = motion_x;
+ s->motion_val[xy][1] = motion_y;
+ s->motion_val[xy + 1][0] = motion_x;
+ s->motion_val[xy + 1][1] = motion_y;
+ s->motion_val[xy + wrap][0] = motion_x;
+ s->motion_val[xy + wrap][1] = motion_y;
+ s->motion_val[xy + 1 + wrap][0] = motion_x;
+ s->motion_val[xy + 1 + wrap][1] = motion_y;
+ }
+
+ if(s->encoding){ //FIXME encoding MUST be cleaned up
+ if (s->mv_type == MV_TYPE_8X8)
+ s->current_picture.mb_type[mb_xy]= MB_TYPE_L0 | MB_TYPE_8x8;
+ else
+ s->current_picture.mb_type[mb_xy]= MB_TYPE_L0 | MB_TYPE_16x16;
+ }
+}
+
#ifdef CONFIG_ENCODERS
+
+static inline int get_p_cbp(MpegEncContext * s,
+ DCTELEM block[6][64],
+ int motion_x, int motion_y){
+ int cbp, i;
+
+ if(s->flags & CODEC_FLAG_CBP_RD){
+ int best_cbpy_score= INT_MAX;
+ int best_cbpc_score= INT_MAX;
+ int cbpc, cbpy;
+ const int offset= (s->mv_type==MV_TYPE_16X16 ? 0 : 16) + (s->dquant ? 8 : 0);
+ const int lambda= s->lambda2 >> (FF_LAMBDA_SHIFT - 6);
+
+ for(i=0; i<4; i++){
+ int score= inter_MCBPC_bits[i + offset] * lambda;
+ if(i&1) score += s->coded_score[5];
+ if(i&2) score += s->coded_score[4];
+
+ if(score < best_cbpc_score){
+ best_cbpc_score= score;
+ cbpc= i;
+ }
+ }
+
+ for(i=0; i<16; i++){
+ int score= cbpy_tab[i ^ 0xF][1] * lambda;
+ if(i&1) score += s->coded_score[3];
+ if(i&2) score += s->coded_score[2];
+ if(i&4) score += s->coded_score[1];
+ if(i&8) score += s->coded_score[0];
+
+ if(score < best_cbpy_score){
+ best_cbpy_score= score;
+ cbpy= i;
+ }
+ }
+ cbp= cbpc + 4*cbpy;
+ if ((motion_x | motion_y | s->dquant) == 0 && s->mv_type==MV_TYPE_16X16){
+ if(best_cbpy_score + best_cbpc_score + 2*lambda >= 0)
+ cbp= 0;
+ }
+
+ for (i = 0; i < 6; i++) {
+ if (s->block_last_index[i] >= 0 && ((cbp >> (5 - i))&1)==0 ){
+ s->block_last_index[i]= -1;
+ memset(s->block[i], 0, sizeof(DCTELEM)*64);
+ }
+ }
+ }else{
+ cbp= 0;
+ for (i = 0; i < 6; i++) {
+ if (s->block_last_index[i] >= 0)
+ cbp |= 1 << (5 - i);
+ }
+ }
+ return cbp;
+}
+
+static inline int get_b_cbp(MpegEncContext * s, DCTELEM block[6][64],
+ int motion_x, int motion_y, int mb_type){
+ int cbp=0, i;
+
+ if(s->flags & CODEC_FLAG_CBP_RD){
+ int score=0;
+ const int lambda= s->lambda2 >> (FF_LAMBDA_SHIFT - 6);
+
+ for(i=0; i<6; i++){
+ if(s->coded_score[i] < 0){
+ score += s->coded_score[i];
+ cbp |= 1 << (5 - i);
+ }
+ }
+
+ if(cbp){
+ int zero_score= -6;
+ if ((motion_x | motion_y | s->dquant | mb_type) == 0){
+ zero_score-= 4; //2*MV + mb_type + cbp bit
+ }
+
+ zero_score*= lambda;
+ if(zero_score <= score){
+ cbp=0;
+ }
+ }
+
+ for (i = 0; i < 6; i++) {
+ if (s->block_last_index[i] >= 0 && ((cbp >> (5 - i))&1)==0 ){
+ s->block_last_index[i]= -1;
+ memset(s->block[i], 0, sizeof(DCTELEM)*64);
+ }
+ }
+ }else{
+ for (i = 0; i < 6; i++) {
+ if (s->block_last_index[i] >= 0)
+ cbp |= 1 << (5 - i);
+ }
+ }
+ return cbp;
+}
+
void mpeg4_encode_mb(MpegEncContext * s,
DCTELEM block[6][64],
int motion_x, int motion_y)
{
int cbpc, cbpy, pred_x, pred_y;
- int bits;
PutBitContext * const pb2 = s->data_partitioning ? &s->pb2 : &s->pb;
PutBitContext * const tex_pb = s->data_partitioning && s->pict_type!=B_TYPE ? &s->tex_pb : &s->pb;
PutBitContext * const dc_pb = s->data_partitioning && s->pict_type!=I_TYPE ? &s->pb2 : &s->pb;
@@ -480,12 +722,8 @@ void mpeg4_encode_mb(MpegEncContext * s,
// printf("**mb x=%d y=%d\n", s->mb_x, s->mb_y);
if (!s->mb_intra) {
/* compute cbp */
- int i, cbp = 0;
- for (i = 0; i < 6; i++) {
- if (s->block_last_index[i] >= 0)
- cbp |= 1 << (5 - i);
- }
-
+ int i, cbp;
+
if(s->pict_type==B_TYPE){
static const int mb_type_table[8]= {-1, 2, 3, 1,-1,-1,-1, 0}; /* convert from mv_dir to type */
int mb_type= mb_type_table[s->mv_dir];
@@ -515,6 +753,8 @@ void mpeg4_encode_mb(MpegEncContext * s,
return;
}
+ cbp= get_b_cbp(s, block, motion_x, motion_y, mb_type);
+
if ((cbp | motion_x | motion_y | mb_type) ==0) {
/* direct MB with MV={0,0} */
assert(s->dquant==0);
@@ -605,6 +845,8 @@ void mpeg4_encode_mb(MpegEncContext * s,
s->p_tex_bits+= get_bits_diff(s);
}
}else{ /* s->pict_type==B_TYPE */
+ cbp= get_p_cbp(s, block, motion_x, motion_y);
+
if ((cbp | motion_x | motion_y | s->dquant) == 0 && s->mv_type==MV_TYPE_16X16) {
/* check if the B frames can skip it too, as we must skip it if we skip here
why didnt they just compress the skip-mb bits instead of reusing them ?! */
@@ -743,23 +985,10 @@ void mpeg4_encode_mb(MpegEncContext * s,
}
}
- s->ac_pred= decide_ac_pred(s, block, dir);
-
- if(s->ac_pred){
- for(i=0; i<6; i++){
- uint8_t *st;
- int last_index;
-
- mpeg4_inv_pred_ac(s, block[i], i, dir[i]);
- if (dir[i]==0) st = s->intra_v_scantable.permutated; /* left */
- else st = s->intra_h_scantable.permutated; /* top */
-
- for(last_index=63; last_index>=0; last_index--) //FIXME optimize
- if(block[i][st[last_index]]) break;
- zigzag_last_index[i]= s->block_last_index[i];
- s->block_last_index[i]= last_index;
- scan_table[i]= st;
- }
+ if(s->flags & CODEC_FLAG_AC_PRED){
+ s->ac_pred= decide_ac_pred(s, block, dir, scan_table, zigzag_last_index);
+ if(!s->ac_pred)
+ restore_ac_coeffs(s, block, dir, scan_table, zigzag_last_index);
}else{
for(i=0; i<6; i++)
scan_table[i]= s->intra_scantable.permutated;
@@ -810,23 +1039,8 @@ void mpeg4_encode_mb(MpegEncContext * s,
s->i_count++;
/* restore ac coeffs & last_index stuff if we messed them up with the prediction */
- if(s->ac_pred){
- for(i=0; i<6; i++){
- int j;
- int16_t *ac_val;
-
- ac_val = s->ac_val[0][0] + s->block_index[i] * 16;
-
- if(dir[i]){
- for(j=1; j<8; j++)
- block[i][s->dsp.idct_permutation[j ]]= ac_val[j+8];
- }else{
- for(j=1; j<8; j++)
- block[i][s->dsp.idct_permutation[j<<3]]= ac_val[j ];
- }
- s->block_last_index[i]= zigzag_last_index[i];
- }
- }
+ if(s->ac_pred)
+ restore_ac_coeffs(s, block, dir, scan_table, zigzag_last_index);
}
}
@@ -838,19 +1052,21 @@ void h263_encode_mb(MpegEncContext * s,
int16_t pred_dc;
int16_t rec_intradc[6];
uint16_t *dc_ptr[6];
+ const int interleaved_stats= (s->flags&CODEC_FLAG_PASS1);
const int dquant_code[5]= {1,0,9,2,3};
//printf("**mb x=%d y=%d\n", s->mb_x, s->mb_y);
if (!s->mb_intra) {
/* compute cbp */
- cbp = 0;
- for (i = 0; i < 6; i++) {
- if (s->block_last_index[i] >= 0)
- cbp |= 1 << (5 - i);
- }
+ cbp= get_p_cbp(s, block, motion_x, motion_y);
+
if ((cbp | motion_x | motion_y | s->dquant) == 0) {
/* skip macroblock */
put_bits(&s->pb, 1, 1);
+ if(interleaved_stats){
+ s->misc_bits++;
+ s->last_bits++;
+ }
return;
}
put_bits(&s->pb, 1, 0); /* mb coded */
@@ -865,6 +1081,10 @@ void h263_encode_mb(MpegEncContext * s,
if(s->dquant)
put_bits(&s->pb, 2, dquant_code[s->dquant+2]);
+ if(interleaved_stats){
+ s->misc_bits+= get_bits_diff(s);
+ }
+
/* motion vectors: 16x16 mode only now */
h263_pred_motion(s, 0, &pred_x, &pred_y);
@@ -879,6 +1099,10 @@ void h263_encode_mb(MpegEncContext * s,
/* To prevent Start Code emulation */
put_bits(&s->pb,1,1);
}
+
+ if(interleaved_stats){
+ s->mv_bits+= get_bits_diff(s);
+ }
} else {
int li = s->h263_aic ? 0 : 1;
@@ -946,6 +1170,10 @@ void h263_encode_mb(MpegEncContext * s,
put_bits(&s->pb, cbpy_tab[cbpy][1], cbpy_tab[cbpy][0]);
if(s->dquant)
put_bits(&s->pb, 2, dquant_code[s->dquant+2]);
+
+ if(interleaved_stats){
+ s->misc_bits+= get_bits_diff(s);
+ }
}
for(i=0; i<6; i++) {
@@ -958,6 +1186,16 @@ void h263_encode_mb(MpegEncContext * s,
}
}
+
+ if(interleaved_stats){
+ if (!s->mb_intra) {
+ s->p_tex_bits+= get_bits_diff(s);
+ s->f_count++;
+ }else{
+ s->i_tex_bits+= get_bits_diff(s);
+ s->i_count++;
+ }
+ }
}
#endif
@@ -1460,6 +1698,20 @@ void h263_encode_init(MpegEncContext *s)
s->luma_dc_vlc_length= uni_DCtab_lum_len;
s->chroma_dc_vlc_length= uni_DCtab_chrom_len;
s->ac_esc_length= 7+2+1+6+1+12+1;
+
+ if(s->flags & CODEC_FLAG_GLOBAL_HEADER){
+
+ s->avctx->extradata= av_malloc(1024);
+ init_put_bits(&s->pb, s->avctx->extradata, 1024);
+
+ mpeg4_encode_visual_object_header(s);
+ mpeg4_encode_vol_header(s, 0, 0);
+
+// ff_mpeg4_stuffing(&s->pb); ?
+ flush_put_bits(&s->pb);
+ s->avctx->extradata_size= (get_bit_count(&s->pb)+7)>>3;
+ }
+
break;
case CODEC_ID_H263P:
s->fcode_tab= umv_fcode_tab;
@@ -1467,6 +1719,17 @@ void h263_encode_init(MpegEncContext *s)
s->max_qcoeff= 127;
break;
//Note for mpeg4 & h263 the dc-scale table will be set per frame as needed later
+ case CODEC_ID_FLV1:
+ if (s->h263_flv > 1) {
+ s->min_qcoeff= -1023;
+ s->max_qcoeff= 1023;
+ } else {
+ s->min_qcoeff= -127;
+ s->max_qcoeff= 127;
+ }
+ s->y_dc_scale_table=
+ s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
+ break;
default: //nothing needed default table allready set in mpegvideo.c
s->min_qcoeff= -127;
s->max_qcoeff= 127;
@@ -1528,6 +1791,7 @@ static void h263_encode_block(MpegEncContext * s, DCTELEM * block, int n)
code = get_rl_index(rl, last, run, level);
put_bits(&s->pb, rl->table_vlc[code][1], rl->table_vlc[code][0]);
if (code == rl->n) {
+ if(s->h263_flv <= 1){
put_bits(&s->pb, 1, last);
put_bits(&s->pb, 6, run);
@@ -1540,11 +1804,28 @@ static void h263_encode_block(MpegEncContext * s, DCTELEM * block, int n)
put_bits(&s->pb, 5, slevel & 0x1f);
put_bits(&s->pb, 6, (slevel>>5)&0x3f);
}
+ }else{
+ if(slevel < 64 && slevel > -64) {
+ /* 7-bit level */
+ put_bits(&s->pb, 1, 0);
+ put_bits(&s->pb, 1, last);
+ put_bits(&s->pb, 6, run);
+
+ put_bits(&s->pb, 7, slevel & 0x7f);
+ } else {
+ /* 11-bit level */
+ put_bits(&s->pb, 1, 1);
+ put_bits(&s->pb, 1, last);
+ put_bits(&s->pb, 6, run);
+
+ put_bits(&s->pb, 11, slevel & 0x7ff);
+ }
+ }
} else {
put_bits(&s->pb, 1, sign);
}
- last_non_zero = i;
- }
+ last_non_zero = i;
+ }
}
}
#endif
@@ -1567,13 +1848,6 @@ void ff_mpeg4_stuffing(PutBitContext * pbc)
void ff_set_mpeg4_time(MpegEncContext * s, int picture_number){
int time_div, time_mod;
- if(s->pict_type==I_TYPE){ //we will encode a vol header
- int dummy;
- av_reduce(&s->time_increment_resolution, &dummy, s->avctx->frame_rate, s->avctx->frame_rate_base, (1<<16)-1);
-
- s->time_increment_bits = av_log2(s->time_increment_resolution - 1) + 1;
- }
-
if(s->current_picture.pts)
s->time= (s->current_picture.pts*s->time_increment_resolution + 500*1000)/(1000*1000);
else
@@ -1628,9 +1902,9 @@ static void mpeg4_encode_visual_object_header(MpegEncContext * s){
put_bits(&s->pb, 16, 0);
put_bits(&s->pb, 16, VOS_STARTCODE);
-
+
put_bits(&s->pb, 8, profile_and_level_indication);
-
+
put_bits(&s->pb, 16, 0);
put_bits(&s->pb, 16, VISUAL_OBJ_STARTCODE);
@@ -1668,13 +1942,12 @@ static void mpeg4_encode_vol_header(MpegEncContext * s, int vo_number, int vol_n
put_bits(&s->pb, 4, vo_ver_id); /* is obj layer ver id */
put_bits(&s->pb, 3, 1); /* is obj layer priority */
- float_aspect_to_info(s, s->avctx->aspect_ratio);
+ aspect_to_info(s, s->avctx->sample_aspect_ratio);
put_bits(&s->pb, 4, s->aspect_ratio_info);/* aspect ratio info */
- if (s->aspect_ratio_info == FF_ASPECT_EXTENDED)
- {
- put_bits(&s->pb, 8, s->aspected_width);
- put_bits(&s->pb, 8, s->aspected_height);
+ if (s->aspect_ratio_info == FF_ASPECT_EXTENDED){
+ put_bits(&s->pb, 8, s->avctx->sample_aspect_ratio.num);
+ put_bits(&s->pb, 8, s->avctx->sample_aspect_ratio.den);
}
if(s->low_delay){
@@ -1710,7 +1983,11 @@ static void mpeg4_encode_vol_header(MpegEncContext * s, int vo_number, int vol_n
s->quant_precision=5;
put_bits(&s->pb, 1, 0); /* not 8 bit == false */
put_bits(&s->pb, 1, s->mpeg_quant); /* quant type= (0=h263 style)*/
- if(s->mpeg_quant) put_bits(&s->pb, 2, 0); /* no custom matrixes */
+
+ if(s->mpeg_quant){
+ ff_write_quant_matrix(&s->pb, s->avctx->intra_matrix);
+ ff_write_quant_matrix(&s->pb, s->avctx->inter_matrix);
+ }
if (vo_ver_id != 1)
put_bits(&s->pb, 1, s->quarter_sample);
@@ -1747,8 +2024,10 @@ void mpeg4_encode_picture_header(MpegEncContext * s, int picture_number)
if(s->pict_type==I_TYPE){
if(!(s->flags&CODEC_FLAG_GLOBAL_HEADER)){
- mpeg4_encode_visual_object_header(s);
- mpeg4_encode_vol_header(s, 0, 0);
+ if(s->strict_std_compliance < 2) //HACK, the reference sw is buggy
+ mpeg4_encode_visual_object_header(s);
+ if(s->strict_std_compliance < 2 || picture_number==0) //HACK, the reference sw is buggy
+ mpeg4_encode_vol_header(s, 0, 0);
}
mpeg4_encode_gop_header(s);
}
@@ -1794,8 +2073,6 @@ void mpeg4_encode_picture_header(MpegEncContext * s, int picture_number)
s->y_dc_scale_table= ff_mpeg4_y_dc_scale_table; //FIXME add short header support
s->c_dc_scale_table= ff_mpeg4_c_dc_scale_table;
- s->h_edge_pos= s->width;
- s->v_edge_pos= s->height;
}
#endif //CONFIG_ENCODERS
@@ -1935,49 +2212,6 @@ void mpeg4_pred_ac(MpegEncContext * s, DCTELEM *block, int n,
#ifdef CONFIG_ENCODERS
-static void mpeg4_inv_pred_ac(MpegEncContext * s, DCTELEM *block, int n,
- int dir)
-{
- int i;
- int16_t *ac_val;
- int8_t * const qscale_table= s->current_picture.qscale_table;
-
- /* find prediction */
- ac_val = s->ac_val[0][0] + s->block_index[n] * 16;
-
- if (dir == 0) {
- const int xy= s->mb_x-1 + s->mb_y*s->mb_stride;
- /* left prediction */
- ac_val -= 16;
- if(s->mb_x==0 || s->qscale == qscale_table[xy] || n==1 || n==3){
- /* same qscale */
- for(i=1;i<8;i++) {
- block[s->dsp.idct_permutation[i<<3]] -= ac_val[i];
- }
- }else{
- /* different qscale, we must rescale */
- for(i=1;i<8;i++) {
- block[s->dsp.idct_permutation[i<<3]] -= ROUNDED_DIV(ac_val[i]*qscale_table[xy], s->qscale);
- }
- }
- } else {
- const int xy= s->mb_x + s->mb_y*s->mb_stride - s->mb_stride;
- /* top prediction */
- ac_val -= 16 * s->block_wrap[n];
- if(s->mb_y==0 || s->qscale == qscale_table[xy] || n==2 || n==3){
- /* same qscale */
- for(i=1;i<8;i++) {
- block[s->dsp.idct_permutation[i]] -= ac_val[i + 8];
- }
- }else{
- /* different qscale, we must rescale */
- for(i=1;i<8;i++) {
- block[s->dsp.idct_permutation[i]] -= ROUNDED_DIV(ac_val[i + 8]*qscale_table[xy], s->qscale);
- }
- }
- }
-}
-
/**
* encodes the dc value.
* @param n block index (0-3 are luma, 4-5 are chroma)
@@ -2268,10 +2502,10 @@ void h263_decode_init_vlc(MpegEncContext *s)
if (!done) {
done = 1;
- init_vlc(&intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 8,
+ init_vlc(&intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 9,
intra_MCBPC_bits, 1, 1,
intra_MCBPC_code, 1, 1);
- init_vlc(&inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 25,
+ init_vlc(&inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 28,
inter_MCBPC_bits, 1, 1,
inter_MCBPC_code, 1, 1);
init_vlc(&cbpy_vlc, CBPY_VLC_BITS, 16,
@@ -2351,6 +2585,8 @@ static int h263_decode_gob_header(MpegEncContext *s)
return -1;
s->mb_x= 0;
s->mb_y= s->gob_index* s->gob_number;
+ if(s->mb_y >= s->mb_height)
+ return -1;
#ifdef DEBUG
fprintf(stderr, "\nGN: %u GFID: %u Quant: %u\n", s->gob_number, gfid, s->qscale);
#endif
@@ -2368,8 +2604,8 @@ static inline void memsetw(short *tab, int val, int n)
void ff_mpeg4_init_partitions(MpegEncContext *s)
{
- init_put_bits(&s->tex_pb, s->tex_pb_buffer, PB_BUFFER_SIZE, NULL, NULL);
- init_put_bits(&s->pb2 , s->pb2_buffer , PB_BUFFER_SIZE, NULL, NULL);
+ init_put_bits(&s->tex_pb, s->tex_pb_buffer, PB_BUFFER_SIZE);
+ init_put_bits(&s->pb2 , s->pb2_buffer , PB_BUFFER_SIZE);
}
void ff_mpeg4_merge_partitions(MpegEncContext *s)
@@ -2599,10 +2835,10 @@ void ff_mpeg4_clean_buffers(MpegEncContext *s)
int ff_h263_resync(MpegEncContext *s){
int left, ret;
- if(s->codec_id==CODEC_ID_MPEG4)
+ if(s->codec_id==CODEC_ID_MPEG4){
skip_bits1(&s->gb);
-
- align_get_bits(&s->gb);
+ align_get_bits(&s->gb);
+ }
if(show_bits(&s->gb, 16)==0){
if(s->codec_id==CODEC_ID_MPEG4)
@@ -2709,12 +2945,14 @@ static int mpeg4_decode_partition_a(MpegEncContext *s){
return mb_num-1;
}
- cbpc = get_vlc2(&s->gb, intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 1);
- if (cbpc < 0){
+ do{
+ cbpc = get_vlc2(&s->gb, intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 2);
+ if (cbpc < 0){
+ fprintf(stderr, "cbpc corrupted at %d %d\n", s->mb_x, s->mb_y);
+ return -1;
+ }
+ }while(cbpc == 8);
- fprintf(stderr, "cbpc corrupted at %d %d\n", s->mb_x, s->mb_y);
- return -1;
- }
s->cbp_table[xy]= cbpc & 3;
s->current_picture.mb_type[xy]= MB_TYPE_INTRA;
s->mb_intra = 1;
@@ -2741,6 +2979,7 @@ static int mpeg4_decode_partition_a(MpegEncContext *s){
int16_t * const mot_val= s->motion_val[s->block_index[0]];
const int stride= s->block_wrap[0]*2;
+// do{ //FIXME
bits= show_bits(&s->gb, 17);
if(bits==MOTION_MARKER){
return mb_num-1;
@@ -2765,15 +3004,14 @@ static int mpeg4_decode_partition_a(MpegEncContext *s){
ff_clean_intra_table_entries(s);
continue;
}
+
cbpc = get_vlc2(&s->gb, inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2);
if (cbpc < 0){
fprintf(stderr, "cbpc corrupted at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
- if (cbpc > 20)
- cbpc+=3;
- else if (cbpc == 20)
- fprintf(stderr, "Stuffing !");
+// }while(cbpc == 20);
+
s->cbp_table[xy]= cbpc&(8+3); //8 is dquant
s->mb_intra = ((cbpc & 4) != 0);
@@ -3070,8 +3308,9 @@ int ff_h263_decode_mb(MpegEncContext *s,
int16_t *mot_val;
static int8_t quant_tab[4] = { -1, -2, 1, 2 };
const int xy= s->mb_x + s->mb_y * s->mb_stride;
-
+
if (s->pict_type == P_TYPE || s->pict_type==S_TYPE) {
+ do{
if (get_bits1(&s->gb)) {
/* skip mb */
s->mb_intra = 0;
@@ -3097,12 +3336,11 @@ int ff_h263_decode_mb(MpegEncContext *s,
}
cbpc = get_vlc2(&s->gb, inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2);
//fprintf(stderr, "\tCBPC: %d", cbpc);
- if (cbpc < 0)
+ if (cbpc < 0){
+ fprintf(stderr, "cbpc damaged at %d %d\n", s->mb_x, s->mb_y);
return -1;
- if (cbpc > 20)
- cbpc+=3;
- else if (cbpc == 20)
- fprintf(stderr, "Stuffing !");
+ }
+ }while(cbpc == 20);
dquant = cbpc & 8;
s->mb_intra = ((cbpc & 4) != 0);
@@ -3339,9 +3577,14 @@ int ff_h263_decode_mb(MpegEncContext *s,
}
s->current_picture.mb_type[xy]= mb_type;
} else { /* I-Frame */
- cbpc = get_vlc2(&s->gb, intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 1);
- if (cbpc < 0)
- return -1;
+ do{
+ cbpc = get_vlc2(&s->gb, intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 2);
+ if (cbpc < 0){
+ fprintf(stderr, "I cbpc damaged at %d %d\n", s->mb_x, s->mb_y);
+ return -1;
+ }
+ }while(cbpc == 8);
+
dquant = cbpc & 4;
s->mb_intra = 1;
intra:
@@ -3358,7 +3601,10 @@ intra:
s->ac_pred = 0;
cbpy = get_vlc2(&s->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1);
- if(cbpy<0) return -1;
+ if(cbpy<0){
+ fprintf(stderr, "I cbpy damaged at %d %d\n", s->mb_x, s->mb_y);
+ return -1;
+ }
cbp = (cbpc & 3) | (cbpy << 2);
if (dquant) {
change_qscale(s, quant_tab[get_bits(&s->gb, 2)]);
@@ -3551,16 +3797,27 @@ static int h263_decode_block(MpegEncContext * s, DCTELEM * block,
}
if (code == rl->n) {
/* escape */
- last = get_bits1(&s->gb);
- run = get_bits(&s->gb, 6);
- level = (int8_t)get_bits(&s->gb, 8);
- if(level == -128){
- if (s->h263_rv10) {
- /* XXX: should patch encoder too */
- level = get_sbits(&s->gb, 12);
- }else{
- level = get_bits(&s->gb, 5);
- level |= get_sbits(&s->gb, 6)<<5;
+ if (s->h263_flv > 1) {
+ int is11 = get_bits1(&s->gb);
+ last = get_bits1(&s->gb);
+ run = get_bits(&s->gb, 6);
+ if(is11){
+ level = get_sbits(&s->gb, 11);
+ } else {
+ level = get_sbits(&s->gb, 7);
+ }
+ } else {
+ last = get_bits1(&s->gb);
+ run = get_bits(&s->gb, 6);
+ level = (int8_t)get_bits(&s->gb, 8);
+ if(level == -128){
+ if (s->h263_rv10) {
+ /* XXX: should patch encoder too */
+ level = get_sbits(&s->gb, 12);
+ }else{
+ level = get_bits(&s->gb, 5);
+ level |= get_sbits(&s->gb, 6)<<5;
+ }
}
}
} else {
@@ -3677,6 +3934,7 @@ static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
//Note intra & rvlc should be optimized away if this is inlined
if(intra) {
+ if(s->qscale < s->intra_dc_threshold){
/* DC coef */
if(s->partitioned_frame){
level = s->dc_val[0][ s->block_index[n] ];
@@ -3690,6 +3948,9 @@ static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
}
block[0] = level;
i = 0;
+ }else{
+ i = -1;
+ }
if (!coded)
goto not_coded;
@@ -3813,10 +4074,10 @@ static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
fprintf(stderr, "|level| overflow in 3. esc, qp=%d\n", s->qscale);
return -1;
}
-#if 1
- {
+#if 0
+ if(s->error_resilience >= FF_ER_COMPLIANT){
const int abs_level= ABS(level);
- if(abs_level<=MAX_LEVEL && run<=MAX_RUN && !(s->workaround_bugs&FF_BUG_AC_VLC)){
+ if(abs_level<=MAX_LEVEL && run<=MAX_RUN){
const int run1= run - rl->max_run[last][abs_level] - 1;
if(abs_level <= rl->max_level[last][run]){
fprintf(stderr, "illegal 3. esc, vlc encoding possible\n");
@@ -3889,7 +4150,19 @@ static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
CLOSE_READER(re, &s->gb);
}
not_coded:
- if (s->mb_intra) {
+ if (intra) {
+ if(s->qscale >= s->intra_dc_threshold){
+ uint16_t *dc_val;
+ block[0] += ff_mpeg4_pred_dc(s, n, &dc_val, &dc_pred_dir);
+ if (n < 4) {
+ *dc_val = block[0] * s->y_dc_scale;
+ } else {
+ *dc_val = block[0] * s->c_dc_scale;
+ }
+
+ if(i == -1) i=0;
+ }
+
mpeg4_pred_ac(s, block, n, dc_pred_dir);
if (s->ac_pred) {
i = 63; /* XXX: not optimal */
@@ -3909,7 +4182,7 @@ int h263_decode_picture_header(MpegEncContext *s)
startcode= get_bits(&s->gb, 22-8);
- for(i= s->gb.size_in_bits - get_bits_count(&s->gb); i>0; i--) {
+ for(i= s->gb.size_in_bits - get_bits_count(&s->gb); i>24; i-=8) {
startcode = ((startcode << 8) | get_bits(&s->gb, 8)) & 0x003FFFFF;
if(startcode == 0x20)
@@ -3956,8 +4229,6 @@ int h263_decode_picture_header(MpegEncContext *s)
if (!width)
return -1;
- s->width = width;
- s->height = height;
s->pict_type = I_TYPE + get_bits1(&s->gb);
s->unrestricted_mv = get_bits1(&s->gb);
@@ -3977,6 +4248,9 @@ int h263_decode_picture_header(MpegEncContext *s)
}
s->qscale = get_bits(&s->gb, 5);
skip_bits1(&s->gb); /* Continuous Presence Multipoint mode: off */
+
+ s->width = width;
+ s->height = height;
} else {
int ufep;
@@ -3991,6 +4265,7 @@ int h263_decode_picture_header(MpegEncContext *s)
dprintf("ufep=1, format: %d\n", format);
skip_bits(&s->gb,1); /* Custom PCF */
s->umvplus = get_bits(&s->gb, 1); /* Unrestricted Motion Vector */
+ s->unrestricted_mv = s->umvplus;
skip_bits1(&s->gb); /* Syntax-based Arithmetic Coding (SAC) */
if (get_bits1(&s->gb) != 0) {
s->mv_type = MV_TYPE_8X8; /* Advanced prediction mode */
@@ -4058,11 +4333,10 @@ int h263_decode_picture_header(MpegEncContext *s)
dprintf("\nH.263+ Custom picture: %dx%d\n",width,height);
if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) {
/* aspected dimensions */
- s->aspected_width = get_bits(&s->gb, 8);
- s->aspected_height = get_bits(&s->gb, 8);
+ s->avctx->sample_aspect_ratio.num= get_bits(&s->gb, 8);
+ s->avctx->sample_aspect_ratio.den= get_bits(&s->gb, 8);
}else{
- s->aspected_width = pixel_aspect[s->aspect_ratio_info][0];
- s->aspected_height= pixel_aspect[s->aspect_ratio_info][1];
+ s->avctx->sample_aspect_ratio= pixel_aspect[s->aspect_ratio_info];
}
} else {
width = h263_format[format][0];
@@ -4349,11 +4623,10 @@ static int decode_vol_header(MpegEncContext *s, GetBitContext *gb){
//printf("vo type:%d\n",s->vo_type);
s->aspect_ratio_info= get_bits(gb, 4);
if(s->aspect_ratio_info == FF_ASPECT_EXTENDED){
- s->aspected_width = get_bits(gb, 8); // par_width
- s->aspected_height = get_bits(gb, 8); // par_height
+ s->avctx->sample_aspect_ratio.num= get_bits(gb, 8); // par_width
+ s->avctx->sample_aspect_ratio.den= get_bits(gb, 8); // par_height
}else{
- s->aspected_width = pixel_aspect[s->aspect_ratio_info][0];
- s->aspected_height= pixel_aspect[s->aspect_ratio_info][1];
+ s->avctx->sample_aspect_ratio= pixel_aspect[s->aspect_ratio_info];
}
if ((s->vol_control_parameters=get_bits1(gb))) { /* vol control parameter */
@@ -4388,14 +4661,15 @@ static int decode_vol_header(MpegEncContext *s, GetBitContext *gb){
skip_bits(gb, 4); //video_object_layer_shape_extension
}
- skip_bits1(gb); /* marker */
+ check_marker(gb, "before time_increment_resolution");
s->time_increment_resolution = get_bits(gb, 16);
s->time_increment_bits = av_log2(s->time_increment_resolution - 1) + 1;
if (s->time_increment_bits < 1)
s->time_increment_bits = 1;
- skip_bits1(gb); /* marker */
+
+ check_marker(gb, "before fixed_vop_rate");
if (get_bits1(gb) != 0) { /* fixed_vop_rate */
skip_bits(gb, s->time_increment_bits);
@@ -4485,8 +4759,8 @@ static int decode_vol_header(MpegEncContext *s, GetBitContext *gb){
/* replicate last value */
for(; i<64; i++){
int j= s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
- s->intra_matrix[j]= v;
- s->chroma_intra_matrix[j]= v;
+ s->intra_matrix[j]= last;
+ s->chroma_intra_matrix[j]= last;
}
}
@@ -4606,15 +4880,6 @@ static int decode_user_data(MpegEncContext *s, GetBitContext *gb){
s->divx_version= ver;
s->divx_build= build;
s->divx_packed= e==3 && last=='p';
-#if 0
- if(s->picture_number==0){
- printf("This file was encoded with DivX%d Build%d", ver, build);
- if(s->divx_packed)
- printf("p\n");
- else
- printf("\n");
- }
-#endif
}
/* ffmpeg detection */
@@ -4630,20 +4895,12 @@ static int decode_user_data(MpegEncContext *s, GetBitContext *gb){
if(e==4){
s->ffmpeg_version= ver*256*256 + ver2*256 + ver3;
s->lavc_build= build;
-#if 0
- if(s->picture_number==0)
- printf("This file was encoded with libavcodec build %d\n", build);
-#endif
}
/* xvid detection */
e=sscanf(buf, "XviD%d", &build);
if(e==1){
s->xvid_build= build;
-#if 0
- if(s->picture_number==0)
- printf("This file was encoded with XviD build %d\n", build);
-#endif
}
//printf("User Data: %s\n", buf);
@@ -4654,7 +4911,7 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){
int time_incr, time_increment;
s->pict_type = get_bits(gb, 2) + I_TYPE; /* pict type: I = 0 , P = 1 */
- if(s->pict_type==B_TYPE && s->low_delay && s->vol_control_parameters==0){
+ if(s->pict_type==B_TYPE && s->low_delay && s->vol_control_parameters==0 && !(s->flags & CODEC_FLAG_LOW_DELAY)){
printf("low_delay flag set, but shouldnt, clearing it\n");
s->low_delay=0;
}
@@ -4675,17 +4932,20 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){
check_marker(gb, "before time_increment");
- if(s->picture_number==0 && (show_bits(gb, s->time_increment_bits+1)&1)==0){
+ if(s->time_increment_bits==0){
printf("hmm, seems the headers arnt complete, trying to guess time_increment_bits\n");
-
for(s->time_increment_bits=1 ;s->time_increment_bits<16; s->time_increment_bits++){
if(show_bits(gb, s->time_increment_bits+1)&1) break;
}
+
printf("my guess is %d bits ;)\n",s->time_increment_bits);
}
- time_increment= get_bits(gb, s->time_increment_bits);
+ if(IS_3IV1) time_increment= get_bits1(gb); //FIXME investigate further
+ else time_increment= get_bits(gb, s->time_increment_bits);
+
+// printf("%d %X\n", s->time_increment_bits, time_increment);
//printf(" type:%d modulo_time_base:%d increment:%d\n", s->pict_type, time_incr, time_increment);
if(s->pict_type!=B_TYPE){
s->last_time_base= s->time_base;
@@ -4760,9 +5020,7 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){
//FIXME complexity estimation stuff
if (s->shape != BIN_ONLY_SHAPE) {
- int t;
- t=get_bits(gb, 3); /* intra dc VLC threshold */
-//printf("threshold %d\n", t);
+ s->intra_dc_threshold= mpeg4_dc_threshold[ get_bits(gb, 3) ];
if(!s->progressive_sequence){
s->top_field_first= get_bits1(gb);
s->alternate_scan= get_bits1(gb);
@@ -4810,12 +5068,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 rnd:%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 vot:%d%s dc:%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, 1-s->no_rounding);
+ s->sprite_warping_accuracy, 1-s->no_rounding, s->vo_type, s->vol_control_parameters ? " VOLC" : " ", s->intra_dc_threshold);
}
if(!s->scalability){
@@ -4844,7 +5102,7 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){
s->y_dc_scale_table= ff_mpeg4_y_dc_scale_table; //FIXME add short header support
s->c_dc_scale_table= ff_mpeg4_c_dc_scale_table;
- if(!(s->workaround_bugs&FF_BUG_EDGE)){
+ if(s->workaround_bugs&FF_BUG_EDGE){
s->h_edge_pos= s->width;
s->v_edge_pos= s->height;
}
@@ -4911,20 +5169,18 @@ int ff_mpeg4_decode_picture_header(MpegEncContext * s, GetBitContext *gb)
printf(" at %d\n", get_bits_count(gb));
}
- switch(startcode){
- case 0x120:
- decode_vol_header(s, gb);
- break;
- case USER_DATA_STARTCODE:
+ if(startcode >= 0x120 && startcode <= 0x12F){
+ if(decode_vol_header(s, gb) < 0)
+ return -1;
+ }
+ else if(startcode == USER_DATA_STARTCODE){
decode_user_data(s, gb);
- break;
- case GOP_STARTCODE:
+ }
+ else if(startcode == GOP_STARTCODE){
mpeg4_decode_gop_header(s, gb);
- break;
- case VOP_STARTCODE:
+ }
+ else if(startcode == VOP_STARTCODE){
return decode_vop_header(s, gb);
- default:
- break;
}
align_get_bits(gb);
@@ -4999,3 +5255,85 @@ int intel_h263_decode_picture_header(MpegEncContext *s)
return 0;
}
+int flv_h263_decode_picture_header(MpegEncContext *s)
+{
+ int format, width, height;
+
+ /* picture header */
+ if (get_bits_long(&s->gb, 17) != 1) {
+ fprintf(stderr, "Bad picture start code\n");
+ return -1;
+ }
+ format = get_bits(&s->gb, 5);
+ if (format != 0 && format != 1) {
+ fprintf(stderr, "Bad picture format\n");
+ return -1;
+ }
+ s->h263_flv = format+1;
+ s->picture_number = get_bits(&s->gb, 8); /* picture timestamp */
+ format = get_bits(&s->gb, 3);
+ switch (format) {
+ case 0:
+ width = get_bits(&s->gb, 8);
+ height = get_bits(&s->gb, 8);
+ break;
+ case 1:
+ width = get_bits(&s->gb, 16);
+ height = get_bits(&s->gb, 16);
+ break;
+ case 2:
+ width = 352;
+ height = 288;
+ break;
+ case 3:
+ width = 176;
+ height = 144;
+ break;
+ case 4:
+ width = 128;
+ height = 96;
+ break;
+ case 5:
+ width = 320;
+ height = 240;
+ break;
+ case 6:
+ width = 160;
+ height = 120;
+ break;
+ default:
+ width = height = 0;
+ break;
+ }
+ if ((width == 0) || (height == 0))
+ return -1;
+ s->width = width;
+ s->height = height;
+
+ s->pict_type = I_TYPE + get_bits(&s->gb, 2);
+ if (s->pict_type > P_TYPE)
+ s->pict_type = P_TYPE;
+ skip_bits1(&s->gb); /* deblocking flag */
+ s->qscale = get_bits(&s->gb, 5);
+
+ s->h263_plus = 0;
+
+ s->unrestricted_mv = 1;
+ s->h263_long_vectors = 0;
+
+ /* PEI */
+ while (get_bits1(&s->gb) != 0) {
+ skip_bits(&s->gb, 8);
+ }
+ s->f_code = 1;
+
+ if(s->avctx->debug & FF_DEBUG_PICT_INFO){
+ printf("%c esc_type:%d, qp:%d num:%d\n",
+ av_get_pict_type_char(s->pict_type), s->h263_flv-1, s->qscale, s->picture_number);
+ }
+
+ s->y_dc_scale_table=
+ s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
+
+ return 0;
+}
diff --git a/src/libffmpeg/libavcodec/h263data.h b/src/libffmpeg/libavcodec/h263data.h
index 132ed98a9..809b10da2 100644
--- a/src/libffmpeg/libavcodec/h263data.h
+++ b/src/libffmpeg/libavcodec/h263data.h
@@ -5,46 +5,30 @@
/* intra MCBPC, mb_type = (intra), then (intraq) */
-const uint8_t intra_MCBPC_code[8] = { 1, 1, 2, 3, 1, 1, 2, 3 };
-const uint8_t intra_MCBPC_bits[8] = { 1, 3, 3, 3, 4, 6, 6, 6 };
+const uint8_t intra_MCBPC_code[9] = { 1, 1, 2, 3, 1, 1, 2, 3, 1 };
+const uint8_t intra_MCBPC_bits[9] = { 1, 3, 3, 3, 4, 6, 6, 6, 9 };
/* inter MCBPC, mb_type = (inter), (intra), (interq), (intraq), (inter4v) */
/* Changed the tables for interq and inter4v+q, following the standard ** Juanjo ** */
-const uint8_t inter_MCBPC_code[25] = {
+const uint8_t inter_MCBPC_code[28] = {
1, 3, 2, 5,
3, 4, 3, 3,
3, 7, 6, 5,
4, 4, 3, 2,
2, 5, 4, 5,
- 1, /* Stuffing */
+ 1, 0, 0, 0, /* Stuffing */
2, 12, 14, 15,
};
-const uint8_t inter_MCBPC_bits[25] = {
- 1, 4, 4, 6,
- 5, 8, 8, 7,
- 3, 7, 7, 9,
- 6, 9, 9, 9,
- 3, 7, 7, 8,
- 9, /* Stuffing */
- 11, 13, 13, 13,
+const uint8_t inter_MCBPC_bits[28] = {
+ 1, 4, 4, 6, /* inter */
+ 5, 8, 8, 7, /* intra */
+ 3, 7, 7, 9, /* interQ */
+ 6, 9, 9, 9, /* intraQ */
+ 3, 7, 7, 8, /* inter4 */
+ 9, 0, 0, 0, /* Stuffing */
+ 11, 13, 13, 13,/* inter4Q*/
};
-/* This is the old table
-static const uint8_t inter_MCBPC_code[20] = {
- 1, 3, 2, 5,
- 3, 4, 3, 3,
- 0, 1, 2, 3,
- 4, 4, 3, 2,
- 2, 5, 4, 5,
-};
-static const uint8_t inter_MCBPC_bits[20] = {
- 1, 4, 4, 6,
- 5, 8, 8, 7,
- 12, 12, 12, 12,
- 6, 9, 9, 9,
- 3, 7, 7, 8,
-};*/
-
const uint8_t cbpy_tab[16][2] =
{
{3,4}, {5,5}, {4,5}, {9,4}, {3,5}, {7,4}, {2,6}, {11,4},
diff --git a/src/libffmpeg/libavcodec/h263dec.c b/src/libffmpeg/libavcodec/h263dec.c
index efc43cd67..f83ff5442 100644
--- a/src/libffmpeg/libavcodec/h263dec.c
+++ b/src/libffmpeg/libavcodec/h263dec.c
@@ -57,6 +57,7 @@ int ff_h263_decode_init(AVCodecContext *avctx)
s->decode_mb= ff_h263_decode_mb;
s->low_delay= 1;
avctx->pix_fmt= PIX_FMT_YUV420P;
+ s->unrestricted_mv= 1;
/* select sub codec */
switch(avctx->codec->id) {
@@ -96,6 +97,9 @@ int ff_h263_decode_init(AVCodecContext *avctx)
case CODEC_ID_H263I:
s->h263_intel = 1;
break;
+ case CODEC_ID_FLV1:
+ s->h263_flv = 1;
+ break;
default:
return -1;
}
@@ -162,7 +166,7 @@ static int decode_slice(MpegEncContext *s){
return -1;
}
- /* restore variables which where modified */
+ /* restore variables which were modified */
s->first_slice_line=1;
s->mb_x= s->resync_mb_x;
s->mb_y= s->resync_mb_y;
@@ -205,12 +209,15 @@ static int decode_slice(MpegEncContext *s){
// s->mb_skiped = 0;
//printf("%d %d %06X\n", ret, get_bits_count(&s->gb), show_bits(&s->gb, 24));
ret= s->decode_mb(s, s->block);
-
- MPV_decode_mb(s, s->block);
+
+ if (s->pict_type!=B_TYPE)
+ ff_h263_update_motion_val(s);
if(ret<0){
const int xy= s->mb_x + s->mb_y*s->mb_stride;
if(ret==SLICE_END){
+ MPV_decode_mb(s, s->block);
+
//printf("%d %d %d %06X\n", s->mb_x, s->mb_y, s->gb.size*8 - get_bits_count(&s->gb), show_bits(&s->gb, 24));
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END)&part_mask);
@@ -232,6 +239,8 @@ static int decode_slice(MpegEncContext *s){
return -1;
}
+
+ MPV_decode_mb(s, s->block);
}
ff_draw_horiz_band(s, s->mb_y*16, 16);
@@ -293,9 +302,9 @@ static int decode_slice(MpegEncContext *s){
return 0;
}
- fprintf(stderr, "slice end not reached but screenspace end (%d left %06X)\n",
+ fprintf(stderr, "slice end not reached but screenspace end (%d left %06X, score= %d)\n",
s->gb.size_in_bits - get_bits_count(&s->gb),
- show_bits(&s->gb, 24));
+ show_bits(&s->gb, 24), s->padding_bug_score);
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END)&part_mask);
@@ -382,9 +391,8 @@ int ff_h263_decode_frame(AVCodecContext *avctx,
uint8_t *buf, int buf_size)
{
MpegEncContext *s = avctx->priv_data;
- int ret,i;
+ int ret;
AVFrame *pict = data;
- float new_aspect;
#ifdef PRINT_FRAME_TIME
uint64_t time= rdtsc();
@@ -396,9 +404,17 @@ uint64_t time= rdtsc();
s->flags= avctx->flags;
*data_size = 0;
-
- /* no supplementary picture */
+
+ /* no supplementary picture */
if (buf_size == 0) {
+ /* special case for last picture */
+ if (s->low_delay==0 && s->next_picture_ptr) {
+ *pict= *(AVFrame*)s->next_picture_ptr;
+ s->next_picture_ptr= NULL;
+
+ *data_size = sizeof(AVFrame);
+ }
+
return 0;
}
@@ -449,32 +465,52 @@ retry:
s->low_delay=1;
} else if (s->h263_intel) {
ret = intel_h263_decode_picture_header(s);
+ } else if (s->h263_flv) {
+ ret = flv_h263_decode_picture_header(s);
} else {
ret = h263_decode_picture_header(s);
}
+
+ if(ret==FRAME_SKIPED) return get_consumed_bytes(s, buf_size);
+
+ /* skip if the header was thrashed */
+ if (ret < 0){
+ fprintf(stderr, "header damaged\n");
+ return -1;
+ }
+
avctx->has_b_frames= !s->low_delay;
+
+ if(s->xvid_build==0 && s->divx_version==0 && s->lavc_build==0){
+ if(s->avctx->stream_codec_tag == ff_get_fourcc("XVID") ||
+ s->avctx->codec_tag == ff_get_fourcc("XVID") || s->avctx->codec_tag == ff_get_fourcc("XVIX"))
+ s->xvid_build= -1;
+#if 0
+ if(s->avctx->codec_tag == ff_get_fourcc("DIVX") && s->vo_type==0 && s->vol_control_parameters==1
+ && s->padding_bug_score > 0 && s->low_delay) // XVID with modified fourcc
+ s->xvid_build= -1;
+#endif
+ }
+
+ if(s->xvid_build==0 && s->divx_version==0 && s->lavc_build==0){
+ if(s->avctx->codec_tag == ff_get_fourcc("DIVX") && s->vo_type==0 && s->vol_control_parameters==0)
+ s->divx_version= 400; //divx 4
+ }
if(s->workaround_bugs&FF_BUG_AUTODETECT){
- if(s->padding_bug_score > -2 && !s->data_partitioning && !s->resync_marker)
+ s->workaround_bugs &= ~FF_BUG_NO_PADDING;
+
+ if(s->padding_bug_score > -2 && !s->data_partitioning && (s->divx_version || !s->resync_marker))
s->workaround_bugs |= FF_BUG_NO_PADDING;
- else
- s->workaround_bugs &= ~FF_BUG_NO_PADDING;
if(s->avctx->codec_tag == ff_get_fourcc("XVIX"))
s->workaround_bugs|= FF_BUG_XVID_ILACE;
-#if 0
- if(s->avctx->codec_tag == ff_get_fourcc("MP4S"))
- s->workaround_bugs|= FF_BUG_AC_VLC;
-
- if(s->avctx->codec_tag == ff_get_fourcc("M4S2"))
- s->workaround_bugs|= FF_BUG_AC_VLC;
-#endif
+
if(s->avctx->codec_tag == ff_get_fourcc("UMP4")){
s->workaround_bugs|= FF_BUG_UMP4;
- s->workaround_bugs|= FF_BUG_AC_VLC;
}
- if(s->divx_version){
+ if(s->divx_version>=500){
s->workaround_bugs|= FF_BUG_QPEL_CHROMA;
}
@@ -482,18 +518,15 @@ retry:
s->workaround_bugs|= FF_BUG_QPEL_CHROMA2;
}
- if(s->avctx->codec_tag == ff_get_fourcc("XVID") && s->xvid_build==0)
- s->workaround_bugs|= FF_BUG_QPEL_CHROMA;
-
- if(s->avctx->codec_tag == ff_get_fourcc("XVID") && s->xvid_build==0)
- s->padding_bug_score= 256*256*256*64;
-
if(s->xvid_build && s->xvid_build<=3)
s->padding_bug_score= 256*256*256*64;
if(s->xvid_build && s->xvid_build<=1)
s->workaround_bugs|= FF_BUG_QPEL_CHROMA;
+ if(s->xvid_build && s->xvid_build<=12)
+ s->workaround_bugs|= FF_BUG_EDGE;
+
#define SET_QPEL_FUNC(postfix1, postfix2) \
s->dsp.put_ ## postfix1 = ff_put_ ## postfix2;\
s->dsp.put_no_rnd_ ## postfix1 = ff_put_no_rnd_ ## postfix2;\
@@ -505,16 +538,20 @@ retry:
if(s->lavc_build && s->lavc_build<4655)
s->workaround_bugs|= FF_BUG_DIRECT_BLOCKSIZE;
+ if(s->lavc_build && s->lavc_build<4670){
+ s->workaround_bugs|= FF_BUG_EDGE;
+ }
+
if(s->divx_version)
s->workaround_bugs|= FF_BUG_DIRECT_BLOCKSIZE;
//printf("padding_bug_score: %d\n", s->padding_bug_score);
if(s->divx_version==501 && s->divx_build==20020416)
s->padding_bug_score= 256*256*256*64;
- if(s->divx_version>=500){
+ if(s->divx_version && s->divx_version<500){
s->workaround_bugs|= FF_BUG_EDGE;
}
-
+
#if 0
if(s->divx_version==500)
s->padding_bug_score= 256*256*256*64;
@@ -547,6 +584,11 @@ retry:
SET_QPEL_FUNC(qpel_pixels_tab[1][15], qpel8_mc33_old_c)
}
+ if(avctx->debug & FF_DEBUG_BUGS)
+ printf("bugs: %X lavc_build:%d xvid_build:%d divx_version:%d divx_build:%d %s\n",
+ s->workaround_bugs, s->lavc_build, s->xvid_build, s->divx_version, s->divx_build,
+ s->divx_packed ? "p" : "");
+
#if 0 // dump bits per frame / qp / complexity
{
static FILE *f=NULL;
@@ -559,33 +601,23 @@ retry:
/* and other parameters. So then we could init the picture */
/* FIXME: By the way H263 decoder is evolving it should have */
/* an H263EncContext */
- if(s->aspected_height)
- new_aspect= s->aspected_width*s->width / (float)(s->height*s->aspected_height);
- else
- new_aspect=0;
- if ( s->width != avctx->width || s->height != avctx->height
- || ABS(new_aspect - avctx->aspect_ratio) > 0.001) {
+ if ( s->width != avctx->width || s->height != avctx->height) {
/* H.263 could change picture size any time */
+ ParseContext pc= s->parse_context; //FIXME move these demuxng hack to avformat
+ s->parse_context.buffer=0;
MPV_common_end(s);
+ s->parse_context= pc;
}
if (!s->context_initialized) {
avctx->width = s->width;
avctx->height = s->height;
- avctx->aspect_ratio= new_aspect;
goto retry;
}
if((s->codec_id==CODEC_ID_H263 || s->codec_id==CODEC_ID_H263P))
s->gob_index = ff_h263_get_gob_height(s);
-
- if(ret==FRAME_SKIPED) return get_consumed_bytes(s, buf_size);
- /* skip if the header was thrashed */
- if (ret < 0){
- fprintf(stderr, "header damaged\n");
- return -1;
- }
// for hurry_up==5
s->current_picture.pict_type= s->pict_type;
@@ -712,6 +744,7 @@ AVCodec mpeg4_decoder = {
ff_h263_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED,
.options = mpeg4_decoptions,
+ .flush= ff_mpeg_flush,
};
AVCodec h263_decoder = {
@@ -724,6 +757,7 @@ AVCodec h263_decoder = {
ff_h263_decode_end,
ff_h263_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED,
+ .flush= ff_mpeg_flush,
};
AVCodec msmpeg4v1_decoder = {
@@ -791,3 +825,14 @@ AVCodec h263i_decoder = {
mpeg4_decoptions,
};
+AVCodec flv_decoder = {
+ "flv",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_FLV1,
+ sizeof(MpegEncContext),
+ ff_h263_decode_init,
+ NULL,
+ ff_h263_decode_end,
+ ff_h263_decode_frame,
+ CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1
+};
diff --git a/src/libffmpeg/libavcodec/h264.c b/src/libffmpeg/libavcodec/h264.c
index 3858703f0..97589ce82 100644
--- a/src/libffmpeg/libavcodec/h264.c
+++ b/src/libffmpeg/libavcodec/h264.c
@@ -59,9 +59,6 @@ typedef struct SPS{
int profile_idc;
int level_idc;
- int multiple_slice_groups; ///< more_than_one_slice_group_allowed_flag
- int arbitrary_slice_order; ///< arbitrary_slice_order_allowed_flag
- int redundant_slices; ///< redundant_slices_allowed_flag
int log2_max_frame_num; ///< log2_max_frame_num_minus4 + 4
int poc_type; ///< pic_order_cnt_type
int log2_max_poc_lsb; ///< log2_max_pic_order_cnt_lsb_minus4
@@ -70,15 +67,19 @@ typedef struct SPS{
int offset_for_top_to_bottom_field;
int poc_cycle_length; ///< num_ref_frames_in_pic_order_cnt_cycle
int ref_frame_count; ///< num_ref_frames
- int required_frame_num_update_behaviour_flag;
+ int gaps_in_frame_num_allowed_flag;
int mb_width; ///< frame_width_in_mbs_minus1 + 1
int mb_height; ///< frame_height_in_mbs_minus1 + 1
int frame_mbs_only_flag;
int mb_aff; ///<mb_adaptive_frame_field_flag
int direct_8x8_inference_flag;
+ int crop; ///< frame_cropping_flag
+ int crop_left; ///< frame_cropping_rect_left_offset
+ int crop_right; ///< frame_cropping_rect_right_offset
+ int crop_top; ///< frame_cropping_rect_top_offset
+ int crop_bottom; ///< frame_cropping_rect_bottom_offset
int vui_parameters_present_flag;
- int sar_width;
- int sar_height;
+ AVRational sar;
short offset_for_ref_frame[256]; //FIXME dyn aloc?
}SPS;
@@ -100,11 +101,6 @@ typedef struct PPS{
int deblocking_filter_parameters_present; ///< deblocking_filter_parameters_present_flag
int constrained_intra_pred; ///< constrained_intra_pred_flag
int redundant_pic_cnt_present; ///< redundant_pic_cnt_present_flag
- int crop; ///< frame_cropping_flag
- int crop_left; ///< frame_cropping_rect_left_offset
- int crop_right; ///< frame_cropping_rect_right_offset
- int crop_top; ///< frame_cropping_rect_top_offset
- int crop_bottom; ///< frame_cropping_rect_bottom_offset
}PPS;
/**
@@ -383,6 +379,9 @@ static inline void fill_caches(H264Context *h, int mb_type){
if(h->sps.mb_aff){
//FIXME
+ topleft_xy = 0; /* avoid warning */
+ top_xy = 0; /* avoid warning */
+ topright_xy = 0; /* avoid warning */
}else{
topleft_xy = mb_xy-1 - s->mb_stride;
top_xy = mb_xy - s->mb_stride;
@@ -789,7 +788,6 @@ static inline void pred_motion(H264Context * const h, int n, int part_width, int
diagonal_ref= fetch_diagonal_mv(h, &C, index8, list, part_width);
match_count= (diagonal_ref==ref) + (top_ref==ref) + (left_ref==ref);
-
if(match_count > 1){ //most common
*mx= mid_pred(A[0], B[0], C[0]);
*my= mid_pred(A[1], B[1], C[1]);
@@ -2106,16 +2104,6 @@ static void init_pred_ptrs(H264Context *h){
h->pred16x16[DC_128_PRED8x8 ]= pred16x16_128_dc_c;
}
-//FIXME factorize
-#define CHECKED_ALLOCZ(p, size)\
-{\
- p= av_mallocz(size);\
- if(p==NULL){\
- perror("malloc");\
- goto fail;\
- }\
-}
-
static void free_tables(H264Context *h){
av_freep(&h->intra4x4_pred_mode);
av_freep(&h->non_zero_count);
@@ -2840,7 +2828,6 @@ static int decode_slice_header(H264Context *h){
int first_mb_in_slice, pps_id;
int num_ref_idx_active_override_flag;
static const uint8_t slice_type_map[5]= {P_TYPE, B_TYPE, I_TYPE, SP_TYPE, SI_TYPE};
- float new_aspect;
s->current_picture.reference= h->nal_ref_idc != 0;
@@ -2886,24 +2873,14 @@ static int decode_slice_header(H264Context *h){
s->mb_x = first_mb_in_slice % s->mb_width;
s->mb_y = first_mb_in_slice / s->mb_width; //FIXME AFFW
- s->width = 16*s->mb_width - 2*(h->pps.crop_left + h->pps.crop_right );
+ s->width = 16*s->mb_width - 2*(h->sps.crop_left + h->sps.crop_right );
if(h->sps.frame_mbs_only_flag)
- s->height= 16*s->mb_height - 2*(h->pps.crop_top + h->pps.crop_bottom);
+ s->height= 16*s->mb_height - 2*(h->sps.crop_top + h->sps.crop_bottom);
else
- s->height= 16*s->mb_height - 4*(h->pps.crop_top + h->pps.crop_bottom); //FIXME recheck
+ s->height= 16*s->mb_height - 4*(h->sps.crop_top + h->sps.crop_bottom); //FIXME recheck
- if(h->pps.crop_left || h->pps.crop_top){
- fprintf(stderr, "insane croping not completly supported, this could look slightly wrong ...\n");
- }
-
- if(s->aspected_height) //FIXME emms at end of slice ?
- new_aspect= h->sps.sar_width*s->width / (float)(s->height*h->sps.sar_height);
- else
- new_aspect=0;
-
if (s->context_initialized
- && ( s->width != s->avctx->width || s->height != s->avctx->height
- || ABS(new_aspect - s->avctx->aspect_ratio) > 0.001)) {
+ && ( s->width != s->avctx->width || s->height != s->avctx->height)) {
free_tables(h);
MPV_common_end(s);
}
@@ -2915,7 +2892,7 @@ static int decode_slice_header(H264Context *h){
s->avctx->width = s->width;
s->avctx->height = s->height;
- s->avctx->aspect_ratio= new_aspect;
+ s->avctx->sample_aspect_ratio= h->sps.sar;
}
if(first_mb_in_slice == 0){
@@ -2943,7 +2920,7 @@ static int decode_slice_header(H264Context *h){
}
if(h->nal_unit_type == NAL_IDR_SLICE){
- int idr_pic_id= get_ue_golomb(&s->gb);
+ get_ue_golomb(&s->gb); /* idr_pic_id */
}
if(h->sps.poc_type==0){
@@ -3006,10 +2983,10 @@ static int decode_slice_header(H264Context *h){
s->qscale = h->pps.init_qp + get_se_golomb(&s->gb); //slice_qp_delta
//FIXME qscale / qp ... stuff
if(h->slice_type == SP_TYPE){
- int sp_for_switch_flag= get_bits1(&s->gb);
+ get_bits1(&s->gb); /* sp_for_switch_flag */
}
if(h->slice_type==SP_TYPE || h->slice_type == SI_TYPE){
- int slice_qs_delta= get_se_golomb(&s->gb);
+ get_se_golomb(&s->gb); /* slice_qs_delta */
}
if( h->pps.deblocking_filter_parameters_present ) {
@@ -3216,7 +3193,8 @@ static int decode_mb(H264Context *h){
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);
-
+ cbp = 0; /* avoid warning. FIXME: find a solution without slowing
+ down the code */
if(h->slice_type != I_TYPE && h->slice_type != SI_TYPE){
if(s->mb_skip_run==-1)
s->mb_skip_run= get_ue_golomb(&s->gb);
@@ -3750,18 +3728,17 @@ static inline int decode_vui_parameters(H264Context *h, SPS *sps){
if( aspect_ratio_info_present_flag ) {
aspect_ratio_idc= get_bits(&s->gb, 8);
if( aspect_ratio_idc == EXTENDED_SAR ) {
- sps->sar_width= get_bits(&s->gb, 16);
- sps->sar_height= get_bits(&s->gb, 16);
+ sps->sar.num= get_bits(&s->gb, 16);
+ sps->sar.den= get_bits(&s->gb, 16);
}else if(aspect_ratio_idc < 16){
- sps->sar_width= pixel_aspect[aspect_ratio_idc][0];
- sps->sar_height= pixel_aspect[aspect_ratio_idc][1];
+ sps->sar= pixel_aspect[aspect_ratio_idc];
}else{
fprintf(stderr, "illegal aspect ratio\n");
return -1;
}
}else{
- sps->sar_width=
- sps->sar_height= 0;
+ sps->sar.num=
+ sps->sar.den= 0;
}
// s->avctx->aspect_ratio= sar_width*s->width / (float)(s->height*sar_height);
#if 0
@@ -3817,28 +3794,23 @@ static inline int decode_vui_parameters(H264Context *h, SPS *sps){
static inline int decode_seq_parameter_set(H264Context *h){
MpegEncContext * const s = &h->s;
- int profile_idc, level_idc, multiple_slice_groups, arbitrary_slice_order, redundant_slices;
+ int profile_idc, level_idc;
int sps_id, i;
SPS *sps;
profile_idc= get_bits(&s->gb, 8);
+ get_bits1(&s->gb); //constraint_set0_flag
+ get_bits1(&s->gb); //constraint_set1_flag
+ get_bits1(&s->gb); //constraint_set2_flag
+ get_bits(&s->gb, 5); // reserved
level_idc= get_bits(&s->gb, 8);
- multiple_slice_groups= get_bits1(&s->gb);
- arbitrary_slice_order= get_bits1(&s->gb);
- redundant_slices= get_bits1(&s->gb);
-
sps_id= get_ue_golomb(&s->gb);
sps= &h->sps_buffer[ sps_id ];
-
sps->profile_idc= profile_idc;
sps->level_idc= level_idc;
- sps->multiple_slice_groups= multiple_slice_groups;
- sps->arbitrary_slice_order= arbitrary_slice_order;
- sps->redundant_slices= redundant_slices;
sps->log2_max_frame_num= get_ue_golomb(&s->gb) + 4;
-
sps->poc_type= get_ue_golomb(&s->gb);
if(sps->poc_type == 0){ //FIXME #define
@@ -3858,7 +3830,7 @@ static inline int decode_seq_parameter_set(H264Context *h){
}
sps->ref_frame_count= get_ue_golomb(&s->gb);
- sps->required_frame_num_update_behaviour_flag= get_bits1(&s->gb);
+ sps->gaps_in_frame_num_allowed_flag= get_bits1(&s->gb);
sps->mb_width= get_ue_golomb(&s->gb) + 1;
sps->mb_height= get_ue_golomb(&s->gb) + 1;
sps->frame_mbs_only_flag= get_bits1(&s->gb);
@@ -3869,18 +3841,36 @@ static inline int decode_seq_parameter_set(H264Context *h){
sps->direct_8x8_inference_flag= get_bits1(&s->gb);
+ sps->crop= get_bits1(&s->gb);
+ if(sps->crop){
+ sps->crop_left = get_ue_golomb(&s->gb);
+ sps->crop_right = get_ue_golomb(&s->gb);
+ sps->crop_top = get_ue_golomb(&s->gb);
+ sps->crop_bottom= get_ue_golomb(&s->gb);
+ if(sps->crop_left || sps->crop_top){
+ fprintf(stderr, "insane croping not completly supported, this could look slightly wrong ...\n");
+ }
+ }else{
+ sps->crop_left =
+ sps->crop_right =
+ sps->crop_top =
+ sps->crop_bottom= 0;
+ }
+
sps->vui_parameters_present_flag= get_bits1(&s->gb);
if( sps->vui_parameters_present_flag )
decode_vui_parameters(h, sps);
if(s->avctx->debug&FF_DEBUG_PICT_INFO){
- printf("sps:%d profile:%d/%d poc:%d ref:%d %dx%d %s %s %s\n",
+ printf("sps:%d profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%d/%d/%d/%d %s\n",
sps_id, sps->profile_idc, sps->level_idc,
sps->poc_type,
sps->ref_frame_count,
sps->mb_width, sps->mb_height,
sps->frame_mbs_only_flag ? "FRM" : (sps->mb_aff ? "MB-AFF" : "PIC-AFF"),
sps->direct_8x8_inference_flag ? "8B8" : "",
+ sps->crop_left, sps->crop_right,
+ sps->crop_top, sps->crop_bottom,
sps->vui_parameters_present_flag ? "VUI" : ""
);
}
@@ -3948,21 +3938,9 @@ fprintf(stderr, "FMO not supported\n");
pps->deblocking_filter_parameters_present= get_bits1(&s->gb);
pps->constrained_intra_pred= get_bits1(&s->gb);
pps->redundant_pic_cnt_present = get_bits1(&s->gb);
- pps->crop= get_bits1(&s->gb);
- if(pps->crop){
- pps->crop_left = get_ue_golomb(&s->gb);
- pps->crop_right = get_ue_golomb(&s->gb);
- pps->crop_top = get_ue_golomb(&s->gb);
- pps->crop_bottom= get_ue_golomb(&s->gb);
- }else{
- pps->crop_left =
- pps->crop_right =
- pps->crop_top =
- pps->crop_bottom= 0;
- }
if(s->avctx->debug&FF_DEBUG_PICT_INFO){
- printf("pps:%d sps:%d %s slice_groups:%d ref:%d/%d %s qp:%d/%d/%d %s %s %s crop:%d/%d/%d/%d\n",
+ printf("pps:%d sps:%d %s slice_groups:%d ref:%d/%d %s qp:%d/%d/%d %s %s %s\n",
pps_id, pps->sps_id,
pps->cabac ? "CABAC" : "CAVLC",
pps->slice_group_count,
@@ -3971,9 +3949,7 @@ fprintf(stderr, "FMO not supported\n");
pps->init_qp, pps->init_qs, pps->chroma_qp_index_offset,
pps->deblocking_filter_parameters_present ? "LPAR" : "",
pps->constrained_intra_pred ? "CONSTR" : "",
- pps->redundant_pic_cnt_present ? "REDU" : "",
- pps->crop_left, pps->crop_right,
- pps->crop_top, pps->crop_bottom
+ pps->redundant_pic_cnt_present ? "REDU" : ""
);
}
@@ -4012,8 +3988,8 @@ static int decode_nal_units(H264Context *h, uint8_t *buf, int buf_size){
MpegEncContext * const s = &h->s;
AVCodecContext * const avctx= s->avctx;
int buf_index=0;
- int i;
#if 0
+ int i;
for(i=0; i<32; i++){
printf("%X ", buf[i]);
}
@@ -4246,7 +4222,7 @@ int main(){
dsputil_init(&dsp, &avctx);
- init_put_bits(&pb, temp, SIZE, NULL, NULL);
+ init_put_bits(&pb, temp, SIZE);
printf("testing unsigned exp golomb\n");
for(i=0; i<COUNT; i++){
START_TIMER
@@ -4271,7 +4247,7 @@ int main(){
}
- init_put_bits(&pb, temp, SIZE, NULL, NULL);
+ init_put_bits(&pb, temp, SIZE);
printf("testing signed exp golomb\n");
for(i=0; i<COUNT; i++){
START_TIMER
diff --git a/src/libffmpeg/libavcodec/h264data.h b/src/libffmpeg/libavcodec/h264data.h
index 0a7ad5014..40a252253 100644
--- a/src/libffmpeg/libavcodec/h264data.h
+++ b/src/libffmpeg/libavcodec/h264data.h
@@ -51,8 +51,8 @@
#define EXTENDED_SAR 255
-static const uint16_t pixel_aspect[16][2]={
- {0, 0},
+static const AVRational pixel_aspect[14]={
+ {0, 1},
{1, 1},
{12, 11},
{10, 11},
diff --git a/src/libffmpeg/libavcodec/huffyuv.c b/src/libffmpeg/libavcodec/huffyuv.c
index 53c0df0c0..e5e492b9b 100644
--- a/src/libffmpeg/libavcodec/huffyuv.c
+++ b/src/libffmpeg/libavcodec/huffyuv.c
@@ -57,7 +57,7 @@ typedef struct HYuvContext{
int flags;
int picture_number;
int last_slice_end;
- uint8_t __align8 temp[3][2500];
+ uint8_t __align8 temp[3][2560];
uint64_t stats[3][256];
uint8_t len[3][256];
uint32_t bits[3][256];
@@ -153,28 +153,6 @@ static inline void add_median_prediction(uint8_t *dst, uint8_t *src1, uint8_t *d
*left_top= lt;
}
-#ifdef CONFIG_ENCODERS
-//FIXME optimize
-static inline void sub_median_prediction(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w, int *left, int *left_top){
- int i;
- uint8_t l, lt;
-
- l= *left;
- lt= *left_top;
-
- for(i=0; i<w; i++){
- const int pred= mid_pred(l, src1[i], (l + src1[i] - lt)&0xFF);
- lt= src1[i];
- l= src2[i];
- dst[i]= l - pred;
- }
-
- *left= l;
- *left_top= lt;
-}
-
-#endif //CONFIG_ENCODERS
-
static inline void add_left_prediction_bgr32(uint8_t *dst, uint8_t *src, int w, int *red, int *green, int *blue){
int i;
int r,g,b;
@@ -197,7 +175,6 @@ static inline void add_left_prediction_bgr32(uint8_t *dst, uint8_t *src, int w,
*blue= b;
}
-#ifdef CONFIG_ENCODERS
static inline int sub_left_prediction(HYuvContext *s, uint8_t *dst, uint8_t *src, int w, int left){
int i;
if(w<32){
@@ -217,7 +194,7 @@ static inline int sub_left_prediction(HYuvContext *s, uint8_t *dst, uint8_t *src
return src[w-1];
}
}
-#endif //CONFIG_ENCODERS
+
static void read_len_table(uint8_t *dst, GetBitContext *gb){
int i, val, repeat;
@@ -250,8 +227,6 @@ static int generate_bits_table(uint32_t *dst, uint8_t *len_table){
return 0;
}
-#ifdef CONFIG_ENCODERS
-
static void generate_len_table(uint8_t *dst, uint64_t *stats, int size){
uint64_t counts[2*size];
int up[2*size];
@@ -308,8 +283,6 @@ static void generate_len_table(uint8_t *dst, uint64_t *stats, int size){
}
}
-#endif //CONFIG_ENCODERS
-
static int read_huffman_tables(HYuvContext *s, uint8_t *src, int length){
GetBitContext gb;
int i;
@@ -460,21 +433,18 @@ s->bgr32=1;
return 0;
}
-#ifdef CONFIG_ENCODERS
-
static void store_table(HYuvContext *s, uint8_t *len){
int i;
int index= s->avctx->extradata_size;
for(i=0; i<256;){
- int cur=i;
int val= len[i];
- int repeat;
-
- for(; i<256 && len[i]==val; i++);
+ int repeat=0;
- repeat= i - cur;
+ for(; i<256 && len[i]==val && repeat<255; i++)
+ repeat++;
+ assert(val < 32 && val >0 && repeat<256 && repeat>0);
if(repeat>7){
((uint8_t*)s->avctx->extradata)[index++]= val;
((uint8_t*)s->avctx->extradata)[index++]= repeat;
@@ -501,8 +471,8 @@ static int encode_init(AVCodecContext *avctx)
assert(width && height);
- avctx->extradata= av_mallocz(1024*10);
- avctx->stats_out= av_mallocz(1024*10);
+ avctx->extradata= av_mallocz(1024*30);
+ avctx->stats_out= av_mallocz(1024*30);
s->version=2;
avctx->coded_frame= &s->picture;
@@ -583,8 +553,6 @@ static int encode_init(AVCodecContext *avctx)
return 0;
}
-#endif //CONFIG_ENCODERS
-
static void decode_422_bitstream(HYuvContext *s, int count){
int i;
@@ -609,8 +577,6 @@ static void decode_gray_bitstream(HYuvContext *s, int count){
}
}
-#ifdef CONFIG_ENCODERS
-
static void encode_422_bitstream(HYuvContext *s, int count){
int i;
@@ -649,8 +615,6 @@ static void encode_gray_bitstream(HYuvContext *s, int count){
}
}
-#endif //CONFIG_ENCODERS
-
static void decode_bgr_bitstream(HYuvContext *s, int count){
int i;
@@ -689,7 +653,7 @@ static void decode_bgr_bitstream(HYuvContext *s, int count){
static void draw_slice(HYuvContext *s, int y){
int h, cy;
- uint8_t *src_ptr[3];
+ int offset[4];
if(s->avctx->draw_horiz_band==NULL)
return;
@@ -702,13 +666,14 @@ static void draw_slice(HYuvContext *s, int y){
}else{
cy= y;
}
-
- src_ptr[0] = s->picture.data[0] + s->picture.linesize[0]*y;
- src_ptr[1] = s->picture.data[1] + s->picture.linesize[1]*cy;
- src_ptr[2] = s->picture.data[2] + s->picture.linesize[2]*cy;
+
+ offset[0] = s->picture.linesize[0]*y;
+ offset[1] = s->picture.linesize[1]*cy;
+ offset[2] = s->picture.linesize[2]*cy;
+ offset[3] = 0;
emms_c();
- s->avctx->draw_horiz_band(s->avctx, src_ptr, s->picture.linesize[0], y, s->width, h);
+ s->avctx->draw_horiz_band(s->avctx, &s->picture, offset, y, 3, h);
s->last_slice_end= y + h;
}
@@ -961,8 +926,6 @@ static int decode_end(AVCodecContext *avctx)
return 0;
}
-#ifdef CONFIG_ENCODERS
-
static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){
HYuvContext *s = avctx->priv_data;
AVFrame *pict = data;
@@ -975,7 +938,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
AVFrame * const p= &s->picture;
int i, size;
- init_put_bits(&s->pb, buf, buf_size, NULL, NULL);
+ init_put_bits(&s->pb, buf, buf_size);
*p = *pict;
p->pict_type= FF_I_TYPE;
@@ -1016,9 +979,9 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
lefttopy= p->data[0][3];
lefttopu= p->data[1][1];
lefttopv= p->data[2][1];
- sub_median_prediction(s->temp[0], p->data[0]+4, p->data[0] + fake_ystride+4, width-4 , &lefty, &lefttopy);
- sub_median_prediction(s->temp[1], p->data[1]+2, p->data[1] + fake_ustride+2, width2-2, &leftu, &lefttopu);
- sub_median_prediction(s->temp[2], p->data[2]+2, p->data[2] + fake_vstride+2, width2-2, &leftv, &lefttopv);
+ s->dsp.sub_hfyu_median_prediction(s->temp[0], p->data[0]+4, p->data[0] + fake_ystride+4, width-4 , &lefty, &lefttopy);
+ s->dsp.sub_hfyu_median_prediction(s->temp[1], p->data[1]+2, p->data[1] + fake_ustride+2, width2-2, &leftu, &lefttopu);
+ s->dsp.sub_hfyu_median_prediction(s->temp[2], p->data[2]+2, p->data[2] + fake_vstride+2, width2-2, &leftv, &lefttopv);
encode_422_bitstream(s, width-4);
y++; cy++;
@@ -1028,7 +991,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
if(s->bitstream_bpp==12){
while(2*cy > y){
ydst= p->data[0] + p->linesize[0]*y;
- sub_median_prediction(s->temp[0], ydst - fake_ystride, ydst, width , &lefty, &lefttopy);
+ s->dsp.sub_hfyu_median_prediction(s->temp[0], ydst - fake_ystride, ydst, width , &lefty, &lefttopy);
encode_gray_bitstream(s, width);
y++;
}
@@ -1038,9 +1001,9 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
udst= p->data[1] + p->linesize[1]*cy;
vdst= p->data[2] + p->linesize[2]*cy;
- sub_median_prediction(s->temp[0], ydst - fake_ystride, ydst, width , &lefty, &lefttopy);
- sub_median_prediction(s->temp[1], udst - fake_ustride, udst, width2, &leftu, &lefttopu);
- sub_median_prediction(s->temp[2], vdst - fake_vstride, vdst, width2, &leftv, &lefttopv);
+ s->dsp.sub_hfyu_median_prediction(s->temp[0], ydst - fake_ystride, ydst, width , &lefty, &lefttopy);
+ s->dsp.sub_hfyu_median_prediction(s->temp[1], udst - fake_ustride, udst, width2, &leftu, &lefttopu);
+ s->dsp.sub_hfyu_median_prediction(s->temp[2], vdst - fake_vstride, vdst, width2, &leftv, &lefttopv);
encode_422_bitstream(s, width);
}
@@ -1071,11 +1034,11 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
if(s->predictor == PLANE && s->interlaced < cy){
s->dsp.diff_bytes(s->temp[1], ydst, ydst - fake_ystride, width);
s->dsp.diff_bytes(s->temp[2], udst, udst - fake_ustride, width2);
- s->dsp.diff_bytes(s->temp[3], vdst, vdst - fake_vstride, width2);
+ s->dsp.diff_bytes(s->temp[2] + 1250, vdst, vdst - fake_vstride, width2);
lefty= sub_left_prediction(s, s->temp[0], s->temp[1], width , lefty);
leftu= sub_left_prediction(s, s->temp[1], s->temp[2], width2, leftu);
- leftv= sub_left_prediction(s, s->temp[2], s->temp[3], width2, leftv);
+ leftv= sub_left_prediction(s, s->temp[2], s->temp[2] + 1250, width2, leftv);
}else{
lefty= sub_left_prediction(s, s->temp[0], ydst, width , lefty);
leftu= sub_left_prediction(s, s->temp[1], udst, width2, leftu);
@@ -1130,8 +1093,6 @@ static const AVOption huffyuv_options[] =
AVOPTION_END()
};
-#endif //CONFIG_ENCODERS
-
AVCodec huffyuv_decoder = {
"huffyuv",
CODEC_TYPE_VIDEO,
diff --git a/src/libffmpeg/libavcodec/i386/dsputil_mmx.c b/src/libffmpeg/libavcodec/i386/dsputil_mmx.c
index d58ebcc4e..c523be74a 100644
--- a/src/libffmpeg/libavcodec/i386/dsputil_mmx.c
+++ b/src/libffmpeg/libavcodec/i386/dsputil_mmx.c
@@ -171,6 +171,7 @@ static const uint64_t ff_pw_15 __attribute__ ((aligned(8))) = 0x000F000F000F000F
/***********************************/
/* standard MMX */
+#ifdef CONFIG_ENCODERS
static void get_pixels_mmx(DCTELEM *block, const uint8_t *pixels, int line_size)
{
asm volatile(
@@ -227,6 +228,7 @@ static inline void diff_pixels_mmx(DCTELEM *block, const uint8_t *s1, const uint
: "%eax"
);
}
+#endif //CONFIG_ENCODERS
void put_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size)
{
@@ -401,6 +403,7 @@ static void clear_blocks_mmx(DCTELEM *blocks)
);
}
+#ifdef CONFIG_ENCODERS
static int pix_sum16_mmx(uint8_t * pix, int line_size){
const int h=16;
int sum;
@@ -438,6 +441,7 @@ static int pix_sum16_mmx(uint8_t * pix, int line_size){
return sum;
}
+#endif //CONFIG_ENCODERS
static void add_bytes_mmx(uint8_t *dst, uint8_t *src, int w){
int i=0;
@@ -461,6 +465,7 @@ static void add_bytes_mmx(uint8_t *dst, uint8_t *src, int w){
dst[i+0] += src[i+0];
}
+#ifdef CONFIG_ENCODERS
static int pix_norm1_mmx(uint8_t *pix, int line_size) {
int tmp;
asm volatile (
@@ -583,6 +588,43 @@ static void diff_bytes_mmx(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){
for(; i<w; i++)
dst[i+0] = src1[i+0]-src2[i+0];
}
+
+static void sub_hfyu_median_prediction_mmx2(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w, int *left, int *left_top){
+ int i=0;
+ uint8_t l, lt;
+
+ asm volatile(
+ "1: \n\t"
+ "movq -1(%1, %0), %%mm0 \n\t" // LT
+ "movq (%1, %0), %%mm1 \n\t" // T
+ "movq -1(%2, %0), %%mm2 \n\t" // L
+ "movq (%2, %0), %%mm3 \n\t" // X
+ "movq %%mm2, %%mm4 \n\t" // L
+ "psubb %%mm0, %%mm2 \n\t"
+ "paddb %%mm1, %%mm2 \n\t" // L + T - LT
+ "movq %%mm4, %%mm5 \n\t" // L
+ "pmaxub %%mm1, %%mm4 \n\t" // max(T, L)
+ "pminub %%mm5, %%mm1 \n\t" // min(T, L)
+ "pminub %%mm2, %%mm4 \n\t"
+ "pmaxub %%mm1, %%mm4 \n\t"
+ "psubb %%mm4, %%mm3 \n\t" // dst - pred
+ "movq %%mm3, (%3, %0) \n\t"
+ "addl $8, %0 \n\t"
+ "cmpl %4, %0 \n\t"
+ " jb 1b \n\t"
+ : "+r" (i)
+ : "r"(src1), "r"(src2), "r"(dst), "r"(w)
+ );
+
+ l= *left;
+ lt= *left_top;
+
+ dst[0]= src2[0] - mid_pred(l, src1[0], (l + src1[0] - lt)&0xFF);
+
+ *left_top= src1[w-1];
+ *left = src2[w-1];
+}
+
#define LBUTTERFLY2(a1,b1,a2,b2)\
"paddw " #b1 ", " #a1 " \n\t"\
"paddw " #b2 ", " #a2 " \n\t"\
@@ -819,6 +861,7 @@ static int hadamard8_diff_mmx2(void *s, uint8_t *src1, uint8_t *src2, int stride
WARPER88_1616(hadamard8_diff_mmx, hadamard8_diff16_mmx)
WARPER88_1616(hadamard8_diff_mmx2, hadamard8_diff16_mmx2)
+#endif //CONFIG_ENCODERS
#define put_no_rnd_pixels8_mmx(a,b,c,d) put_pixels8_mmx(a,b,c,d)
#define put_no_rnd_pixels16_mmx(a,b,c,d) put_pixels16_mmx(a,b,c,d)
@@ -1567,24 +1610,31 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SIMPLEMMX){
c->idct_put= ff_simple_idct_put_mmx;
c->idct_add= ff_simple_idct_add_mmx;
+ c->idct = ff_simple_idct_mmx;
c->idct_permutation_type= FF_SIMPLE_IDCT_PERM;
}else if(idct_algo==FF_IDCT_LIBMPEG2MMX){
if(mm_flags & MM_MMXEXT){
c->idct_put= ff_libmpeg2mmx2_idct_put;
c->idct_add= ff_libmpeg2mmx2_idct_add;
+ c->idct = ff_mmxext_idct;
}else{
c->idct_put= ff_libmpeg2mmx_idct_put;
c->idct_add= ff_libmpeg2mmx_idct_add;
+ c->idct = ff_mmx_idct;
}
c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;
}
+#ifdef CONFIG_ENCODERS
c->get_pixels = get_pixels_mmx;
c->diff_pixels = diff_pixels_mmx;
+#endif //CONFIG_ENCODERS
c->put_pixels_clamped = put_pixels_clamped_mmx;
c->add_pixels_clamped = add_pixels_clamped_mmx;
c->clear_blocks = clear_blocks_mmx;
+#ifdef CONFIG_ENCODERS
c->pix_sum = pix_sum16_mmx;
+#endif //CONFIG_ENCODERS
c->put_pixels_tab[0][0] = put_pixels16_mmx;
c->put_pixels_tab[0][1] = put_pixels16_x2_mmx;
@@ -1627,6 +1677,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
c->avg_no_rnd_pixels_tab[1][3] = avg_no_rnd_pixels8_xy2_mmx;
c->add_bytes= add_bytes_mmx;
+#ifdef CONFIG_ENCODERS
c->diff_bytes= diff_bytes_mmx;
c->hadamard8_diff[0]= hadamard8_diff16_mmx;
@@ -1634,6 +1685,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
c->pix_norm1 = pix_norm1_mmx;
c->sse[0] = sse16_mmx;
+#endif //CONFIG_ENCODERS
if (mm_flags & MM_MMXEXT) {
c->put_pixels_tab[0][1] = put_pixels16_x2_mmx2;
@@ -1650,8 +1702,10 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
c->avg_pixels_tab[1][1] = avg_pixels8_x2_mmx2;
c->avg_pixels_tab[1][2] = avg_pixels8_y2_mmx2;
+#ifdef CONFIG_ENCODERS
c->hadamard8_diff[0]= hadamard8_diff16_mmx2;
c->hadamard8_diff[1]= hadamard8_diff_mmx2;
+#endif //CONFIG_ENCODERS
if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_mmx2;
@@ -1696,6 +1750,8 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
SET_QPEL_FUNC(qpel_pixels_tab[1][14], qpel8_mc23_mmx2)
SET_QPEL_FUNC(qpel_pixels_tab[1][15], qpel8_mc33_mmx2)
#endif
+
+ c->sub_hfyu_median_prediction= sub_hfyu_median_prediction_mmx2;
} else if (mm_flags & MM_3DNOW) {
c->put_pixels_tab[0][1] = put_pixels16_x2_3dnow;
c->put_pixels_tab[0][2] = put_pixels16_y2_3dnow;
@@ -1755,7 +1811,9 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
}
}
+#ifdef CONFIG_ENCODERS
dsputil_init_pix_mmx(c, avctx);
+#endif //CONFIG_ENCODERS
#if 0
// for speed testing
get_pixels = just_return;
diff --git a/src/libffmpeg/libavcodec/i386/motion_est_mmx.c b/src/libffmpeg/libavcodec/i386/motion_est_mmx.c
index 1bc5dfeb2..aa22f0649 100644
--- a/src/libffmpeg/libavcodec/i386/motion_est_mmx.c
+++ b/src/libffmpeg/libavcodec/i386/motion_est_mmx.c
@@ -26,7 +26,7 @@ static const __attribute__ ((aligned(8))) uint64_t round_tab[3]={
0x0002000200020002,
};
-static const __attribute__ ((aligned(8))) uint64_t bone= 0x0101010101010101LL;
+static const __attribute__ ((aligned(8), unused)) uint64_t bone= 0x0101010101010101LL;
static inline void sad8_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h)
{
diff --git a/src/libffmpeg/libavcodec/i386/mpegvideo_mmx_template.c b/src/libffmpeg/libavcodec/i386/mpegvideo_mmx_template.c
index fa1ab579d..706211eec 100644
--- a/src/libffmpeg/libavcodec/i386/mpegvideo_mmx_template.c
+++ b/src/libffmpeg/libavcodec/i386/mpegvideo_mmx_template.c
@@ -38,7 +38,9 @@ static int RENAME(dct_quantize)(MpegEncContext *s,
{
int level=0, last_non_zero_p1, q; //=0 is cuz gcc says uninitalized ...
const uint16_t *qmat, *bias;
- static __align8 int16_t temp_block[64];
+ __align8 int16_t temp_block[64];
+
+ assert((7&(int)(&temp_block[0])) == 0); //did gcc align it correctly?
//s->fdct (block);
ff_fdct_mmx (block); //cant be anything else ...
diff --git a/src/libffmpeg/libavcodec/i386/simple_idct_mmx.c b/src/libffmpeg/libavcodec/i386/simple_idct_mmx.c
index 836403ca5..626c1f565 100644
--- a/src/libffmpeg/libavcodec/i386/simple_idct_mmx.c
+++ b/src/libffmpeg/libavcodec/i386/simple_idct_mmx.c
@@ -47,8 +47,8 @@
static const uint64_t __attribute__((aligned(8))) wm1010= 0xFFFF0000FFFF0000ULL;
static const uint64_t __attribute__((aligned(8))) d40000= 0x0000000000040000ULL;
-static int16_t __attribute__((aligned(8))) temp[64];
-static int16_t __attribute__((aligned(8))) coeffs[]= {
+
+static const int16_t __attribute__((aligned(8))) coeffs[]= {
1<<(ROW_SHIFT-1), 0, 1<<(ROW_SHIFT-1), 0,
// 1<<(COL_SHIFT-1), 0, 1<<(COL_SHIFT-1), 0,
// 0, 1<<(COL_SHIFT-1-16), 0, 1<<(COL_SHIFT-1-16),
@@ -206,6 +206,9 @@ row[7] = input[13];
static inline void idct(int16_t *block)
{
+ int64_t __attribute__((aligned(8))) align_tmp[16];
+ int16_t * const temp= (int16_t*)align_tmp;
+
asm volatile(
#if 0 //Alternative, simpler variant
diff --git a/src/libffmpeg/libavcodec/idcinvideo.c b/src/libffmpeg/libavcodec/idcinvideo.c
new file mode 100644
index 000000000..d516e39fb
--- /dev/null
+++ b/src/libffmpeg/libavcodec/idcinvideo.c
@@ -0,0 +1,283 @@
+/*
+ * Id Quake II CIN Video Decoder
+ * 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
+ *
+ */
+
+/**
+ * @file idcinvideo.c
+ * Id Quake II Cin Video Decoder by Dr. Tim Ferguson
+ * For more information about the Id CIN format, visit:
+ * http://www.csse.monash.edu.au/~timf/
+ *
+ * This video decoder outputs PAL8 colorspace data. Interacting with this
+ * decoder is a little involved. During initialization, the demuxer must
+ * transmit the 65536-byte Huffman table(s) to the decoder via extradata.
+ * Then, whenever a palette change is encountered while demuxing the file,
+ * the demuxer must use the same extradata space to transmit an
+ * AVPaletteControl structure.
+ *
+ * Id CIN video is purely Huffman-coded, intraframe-only codec. It achieves
+ * a little more compression by exploiting the fact that adjacent pixels
+ * tend to be similar.
+ *
+ * Note that this decoder could use ffmpeg's optimized VLC facilities
+ * rather than naive, tree-based Huffman decoding. However, there are 256
+ * Huffman tables. Plus, the VLC bit coding order is right -> left instead
+ * or left -> right, so all of the bits would have to be reversed. Further,
+ * the original Quake II implementation likely used a similar naive
+ * decoding algorithm and it worked fine on much lower spec machines.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "common.h"
+#include "avcodec.h"
+#include "dsputil.h"
+
+#define HUFFMAN_TABLE_SIZE 64 * 1024
+#define HUF_TOKENS 256
+#define PALETTE_COUNT 256
+
+typedef struct
+{
+ int count;
+ unsigned char used;
+ int children[2];
+} hnode_t;
+
+typedef struct IdcinContext {
+
+ AVCodecContext *avctx;
+ DSPContext dsp;
+ AVFrame frame;
+
+ unsigned char *buf;
+ int size;
+
+ unsigned char palette[PALETTE_COUNT * 4];
+
+ hnode_t huff_nodes[256][HUF_TOKENS*2];
+ int num_huff_nodes[256];
+
+} IdcinContext;
+
+/*
+ * Find the lowest probability node in a Huffman table, and mark it as
+ * being assigned to a higher probability.
+ * Returns the node index of the lowest unused node, or -1 if all nodes
+ * are used.
+ */
+static int huff_smallest_node(hnode_t *hnodes, int num_hnodes) {
+ int i;
+ int best, best_node;
+
+ best = 99999999;
+ best_node = -1;
+ for(i = 0; i < num_hnodes; i++) {
+ if(hnodes[i].used)
+ continue;
+ if(!hnodes[i].count)
+ continue;
+ if(hnodes[i].count < best) {
+ best = hnodes[i].count;
+ best_node = i;
+ }
+ }
+
+ if(best_node == -1)
+ return -1;
+ hnodes[best_node].used = 1;
+ return best_node;
+}
+
+/*
+ * Build the Huffman tree using the generated/loaded probabilities histogram.
+ *
+ * On completion:
+ * huff_nodes[prev][i < HUF_TOKENS] - are the nodes at the base of the tree.
+ * huff_nodes[prev][i >= HUF_TOKENS] - are used to construct the tree.
+ * num_huff_nodes[prev] - contains the index to the root node of the tree.
+ * That is: huff_nodes[prev][num_huff_nodes[prev]] is the root node.
+ */
+static void huff_build_tree(IdcinContext *s, int prev) {
+ hnode_t *node, *hnodes;
+ int num_hnodes, i;
+
+ num_hnodes = HUF_TOKENS;
+ hnodes = s->huff_nodes[prev];
+ for(i = 0; i < HUF_TOKENS * 2; i++)
+ hnodes[i].used = 0;
+
+ while (1) {
+ node = &hnodes[num_hnodes]; /* next free node */
+
+ /* pick two lowest counts */
+ node->children[0] = huff_smallest_node(hnodes, num_hnodes);
+ if(node->children[0] == -1)
+ break; /* reached the root node */
+
+ node->children[1] = huff_smallest_node(hnodes, num_hnodes);
+ if(node->children[1] == -1)
+ break; /* reached the root node */
+
+ /* combine nodes probability for new node */
+ node->count = hnodes[node->children[0]].count +
+ hnodes[node->children[1]].count;
+ num_hnodes++;
+ }
+
+ s->num_huff_nodes[prev] = num_hnodes - 1;
+}
+
+static int idcin_decode_init(AVCodecContext *avctx)
+{
+ IdcinContext *s = (IdcinContext *)avctx->priv_data;
+ int i, j, histogram_index = 0;
+ unsigned char *histograms;
+
+ s->avctx = avctx;
+ avctx->pix_fmt = PIX_FMT_PAL8;
+ avctx->has_b_frames = 0;
+ dsputil_init(&s->dsp, avctx);
+
+ /* make sure the Huffman tables make it */
+ if (s->avctx->extradata_size != HUFFMAN_TABLE_SIZE) {
+ printf(" Id CIN video: expected extradata size of %d\n", HUFFMAN_TABLE_SIZE);
+ return -1;
+ }
+
+ /* build the 256 Huffman decode trees */
+ histograms = (unsigned char *)s->avctx->extradata;
+ for (i = 0; i < 256; i++) {
+ for(j = 0; j < HUF_TOKENS; j++)
+ s->huff_nodes[i][j].count = histograms[histogram_index++];
+ huff_build_tree(s, i);
+ }
+
+ s->frame.data[0] = NULL;
+
+ return 0;
+}
+
+static void idcin_decode_vlcs(IdcinContext *s)
+{
+ hnode_t *hnodes;
+ long x, y;
+ int prev;
+ unsigned char v = 0;
+ int bit_pos, node_num, dat_pos;
+
+ prev = bit_pos = dat_pos = 0;
+ for (y = 0; y < (s->frame.linesize[0] * s->avctx->height);
+ y += s->frame.linesize[0]) {
+ for (x = y; x < y + s->avctx->width; x++) {
+ node_num = s->num_huff_nodes[prev];
+ hnodes = s->huff_nodes[prev];
+
+ while(node_num >= HUF_TOKENS) {
+ if(!bit_pos) {
+ if(dat_pos > s->size) {
+ printf("Huffman decode error.\n");
+ return;
+ }
+ bit_pos = 8;
+ v = s->buf[dat_pos++];
+ }
+
+ node_num = hnodes[node_num].children[v & 0x01];
+ v = v >> 1;
+ bit_pos--;
+ }
+
+ s->frame.data[0][x] = node_num;
+ prev = node_num;
+ }
+ }
+}
+
+static int idcin_decode_frame(AVCodecContext *avctx,
+ void *data, int *data_size,
+ uint8_t *buf, int buf_size)
+{
+ IdcinContext *s = (IdcinContext *)avctx->priv_data;
+ AVPaletteControl *palette_control =
+ (AVPaletteControl *)avctx->extradata;
+ int i;
+ unsigned int *palette32;
+ int palette_index = 0;
+ unsigned char r, g, b;
+
+ s->buf = buf;
+ s->size = buf_size;
+
+ if (palette_control->palette_changed) {
+ palette32 = (unsigned int *)s->palette;
+ for (i = 0; i < PALETTE_COUNT; i++) {
+ r = palette_control->palette[palette_index++] * 1;
+ g = palette_control->palette[palette_index++] * 1;
+ b = palette_control->palette[palette_index++] * 1;
+ palette32[i] = (r << 16) | (g << 8) | (b);
+ }
+ palette_control->palette_changed = 0;
+ }
+
+ if (s->frame.data[0])
+ avctx->release_buffer(avctx, &s->frame);
+
+ if (avctx->get_buffer(avctx, &s->frame)) {
+ printf (" Id CIN Video: get_buffer() failed\n");
+ return -1;
+ }
+
+ idcin_decode_vlcs(s);
+
+ /* make the palette available on the way out */
+ memcpy(s->frame.data[1], s->palette, PALETTE_COUNT * 4);
+
+ *data_size = sizeof(AVFrame);
+ *(AVFrame*)data = s->frame;
+
+ /* report that the buffer was completely consumed */
+ return buf_size;
+}
+
+static int idcin_decode_end(AVCodecContext *avctx)
+{
+ IdcinContext *s = (IdcinContext *)avctx->priv_data;
+
+ if (s->frame.data[0])
+ avctx->release_buffer(avctx, &s->frame);
+
+ return 0;
+}
+
+AVCodec idcin_decoder = {
+ "idcinvideo",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_IDCIN,
+ sizeof(IdcinContext),
+ idcin_decode_init,
+ NULL,
+ idcin_decode_end,
+ idcin_decode_frame,
+ CODEC_CAP_DR1,
+};
+
diff --git a/src/libffmpeg/libavcodec/imgconvert.c b/src/libffmpeg/libavcodec/imgconvert.c
index 6a36c8558..f154e4437 100644
--- a/src/libffmpeg/libavcodec/imgconvert.c
+++ b/src/libffmpeg/libavcodec/imgconvert.c
@@ -236,7 +236,7 @@ enum PixelFormat avcodec_get_pix_fmt(const char* name)
/* 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)
+ int pix_fmt, int width, int height)
{
int size, w2, h2, size2;
PixFmtInfo *pinfo;
@@ -313,12 +313,12 @@ int avpicture_fill(AVPicture *picture, uint8_t *ptr,
}
}
-int avpicture_layout(AVPicture* src, int pix_fmt, int width, int height,
+int avpicture_layout(const AVPicture* src, int pix_fmt, int width, int height,
unsigned char *dest, int dest_size)
{
PixFmtInfo* pf = &pix_fmt_info[pix_fmt];
int i, j, w, h, data_planes;
- unsigned char* s;
+ const unsigned char* s;
int size = avpicture_get_size(pix_fmt, width, height);
if (size > dest_size)
@@ -535,7 +535,7 @@ static void img_copy_plane(uint8_t *dst, int dst_wrap,
/**
* Copy image 'src' to 'dst'.
*/
-void img_copy(AVPicture *dst, AVPicture *src,
+void img_copy(AVPicture *dst, const AVPicture *src,
int pix_fmt, int width, int height)
{
int bwidth, bits, i;
@@ -588,24 +588,24 @@ void img_copy(AVPicture *dst, AVPicture *src,
/* XXX: totally non optimized */
-static void yuv422_to_yuv420p(AVPicture *dst, AVPicture *src,
+static void yuv422_to_yuv420p(AVPicture *dst, const AVPicture *src,
int width, int height)
{
const uint8_t *p, *p1;
uint8_t *lum, *cr, *cb, *lum1, *cr1, *cb1;
- int x;
+ int w;
p1 = src->data[0];
lum1 = dst->data[0];
cb1 = dst->data[1];
cr1 = dst->data[2];
- for(;height >= 2; height -= 2) {
+ for(;height >= 1; height -= 2) {
p = p1;
lum = lum1;
cb = cb1;
cr = cr1;
- for(x=0;x<width;x+=2) {
+ for(w = width; w >= 2; w -= 2) {
lum[0] = p[0];
cb[0] = p[1];
lum[1] = p[2];
@@ -615,24 +615,36 @@ 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) {
+ if (w) {
lum[0] = p[0];
- lum[1] = p[2];
- p += 4;
- lum += 2;
+ cb[0] = p[1];
+ cr[0] = p[3];
+ cb++;
+ cr++;
}
p1 += src->linesize[0];
lum1 += dst->linesize[0];
+ if (height>1) {
+ p = p1;
+ lum = lum1;
+ for(w = width; w >= 2; w -= 2) {
+ lum[0] = p[0];
+ lum[1] = p[2];
+ p += 4;
+ lum += 2;
+ }
+ if (w) {
+ lum[0] = p[0];
+ }
+ 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,
+static void yuv422_to_yuv422p(AVPicture *dst, const AVPicture *src,
int width, int height)
{
const uint8_t *p, *p1;
@@ -665,7 +677,7 @@ static void yuv422_to_yuv422p(AVPicture *dst, AVPicture *src,
}
}
-static void yuv422p_to_yuv422(AVPicture *dst, AVPicture *src,
+static void yuv422p_to_yuv422(AVPicture *dst, const AVPicture *src,
int width, int height)
{
uint8_t *p, *p1;
@@ -1274,7 +1286,7 @@ static inline unsigned int bitcopy_n(unsigned int a, int n)
#include "imgconvert_template.h"
-static void mono_to_gray(AVPicture *dst, AVPicture *src,
+static void mono_to_gray(AVPicture *dst, const AVPicture *src,
int width, int height, int xor_mask)
{
const unsigned char *p;
@@ -1315,19 +1327,19 @@ static void mono_to_gray(AVPicture *dst, AVPicture *src,
}
}
-static void monowhite_to_gray(AVPicture *dst, AVPicture *src,
+static void monowhite_to_gray(AVPicture *dst, const AVPicture *src,
int width, int height)
{
mono_to_gray(dst, src, width, height, 0xff);
}
-static void monoblack_to_gray(AVPicture *dst, AVPicture *src,
+static void monoblack_to_gray(AVPicture *dst, const AVPicture *src,
int width, int height)
{
mono_to_gray(dst, src, width, height, 0x00);
}
-static void gray_to_mono(AVPicture *dst, AVPicture *src,
+static void gray_to_mono(AVPicture *dst, const AVPicture *src,
int width, int height, int xor_mask)
{
int n;
@@ -1371,20 +1383,21 @@ static void gray_to_mono(AVPicture *dst, AVPicture *src,
}
}
-static void gray_to_monowhite(AVPicture *dst, AVPicture *src,
+static void gray_to_monowhite(AVPicture *dst, const AVPicture *src,
int width, int height)
{
gray_to_mono(dst, src, width, height, 0xff);
}
-static void gray_to_monoblack(AVPicture *dst, AVPicture *src,
+static void gray_to_monoblack(AVPicture *dst, const AVPicture *src,
int width, int height)
{
gray_to_mono(dst, src, width, height, 0x00);
}
typedef struct ConvertEntry {
- void (*convert)(AVPicture *dst, AVPicture *src, int width, int height);
+ void (*convert)(AVPicture *dst,
+ const AVPicture *src, int width, int height);
} ConvertEntry;
/* Add each new convertion function in this table. In order to be able
@@ -1600,7 +1613,7 @@ static ConvertEntry convert_table[PIX_FMT_NB][PIX_FMT_NB] = {
},
};
-static int avpicture_alloc(AVPicture *picture,
+int avpicture_alloc(AVPicture *picture,
int pix_fmt, int width, int height)
{
unsigned int size;
@@ -1617,7 +1630,7 @@ static int avpicture_alloc(AVPicture *picture,
return -1;
}
-static void avpicture_free(AVPicture *picture)
+void avpicture_free(AVPicture *picture)
{
av_free(picture->data[0]);
}
@@ -1632,7 +1645,7 @@ static inline int is_yuv_planar(PixFmtInfo *ps)
/* XXX: always use linesize. Return -1 if not supported */
int img_convert(AVPicture *dst, int dst_pix_fmt,
- AVPicture *src, int src_pix_fmt,
+ const AVPicture *src, int src_pix_fmt,
int src_width, int src_height)
{
static int inited;
@@ -1865,7 +1878,7 @@ int img_convert(AVPicture *dst, int dst_pix_fmt,
}
/* NOTE: we scan all the pixels to have an exact information */
-static int get_alpha_info_pal8(AVPicture *src, int width, int height)
+static int get_alpha_info_pal8(const AVPicture *src, int width, int height)
{
const unsigned char *p;
int src_wrap, ret, x, y;
@@ -1894,7 +1907,8 @@ static int get_alpha_info_pal8(AVPicture *src, int width, int height)
* 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)
+int img_get_alpha_info(const AVPicture *src,
+ int pix_fmt, int width, int height)
{
PixFmtInfo *pf = &pix_fmt_info[pix_fmt];
int ret;
@@ -1969,8 +1983,11 @@ int img_get_alpha_info(AVPicture *src, int pix_fmt, int width, int height)
#endif
/* filter parameters: [-1 4 2 4 -1] // 8 */
-static void deinterlace_line(uint8_t *dst, uint8_t *lum_m4, uint8_t *lum_m3, uint8_t *lum_m2, uint8_t *lum_m1, uint8_t *lum,
- int size)
+static void deinterlace_line(uint8_t *dst,
+ const uint8_t *lum_m4, const uint8_t *lum_m3,
+ const uint8_t *lum_m2, const uint8_t *lum_m1,
+ const uint8_t *lum,
+ int size)
{
#ifndef HAVE_MMX
uint8_t *cm = cropTbl + MAX_NEG_CROP;
@@ -2059,10 +2076,10 @@ static void deinterlace_line_inplace(uint8_t *lum_m4, uint8_t *lum_m3, uint8_t *
top field is copied as is, but the bottom field is deinterlaced
against the top field. */
static void deinterlace_bottom_field(uint8_t *dst, int dst_wrap,
- uint8_t *src1, int src_wrap,
+ const uint8_t *src1, int src_wrap,
int width, int height)
{
- uint8_t *src_m2, *src_m1, *src_0, *src_p1, *src_p2;
+ const uint8_t *src_m2, *src_m1, *src_0, *src_p1, *src_p2;
int y;
src_m2 = src1;
@@ -2088,7 +2105,7 @@ static void deinterlace_bottom_field(uint8_t *dst, int dst_wrap,
}
static void deinterlace_bottom_field_inplace(uint8_t *src1, int src_wrap,
- int width, int height)
+ int width, int height)
{
uint8_t *src_m1, *src_0, *src_p1, *src_p2;
int y;
@@ -2114,14 +2131,15 @@ static void deinterlace_bottom_field_inplace(uint8_t *src1, int src_wrap,
/* deinterlace - if not supported return -1 */
-int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
+int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
int pix_fmt, int width, int height)
{
int i;
if (pix_fmt != PIX_FMT_YUV420P &&
pix_fmt != PIX_FMT_YUV422P &&
- pix_fmt != PIX_FMT_YUV444P)
+ pix_fmt != PIX_FMT_YUV444P &&
+ pix_fmt != PIX_FMT_YUV411P)
return -1;
if ((width & 3) != 0 || (height & 3) != 0)
return -1;
@@ -2136,12 +2154,15 @@ int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
case PIX_FMT_YUV422P:
width >>= 1;
break;
+ case PIX_FMT_YUV411P:
+ width >>= 2;
+ break;
default:
break;
}
}
if (src == dst) {
- deinterlace_bottom_field_inplace(src->data[i], src->linesize[i],
+ deinterlace_bottom_field_inplace(dst->data[i], dst->linesize[i],
width, height);
} else {
deinterlace_bottom_field(dst->data[i],dst->linesize[i],
diff --git a/src/libffmpeg/libavcodec/imgconvert_template.h b/src/libffmpeg/libavcodec/imgconvert_template.h
index 015b74f1e..cd5a7313c 100644
--- a/src/libffmpeg/libavcodec/imgconvert_template.h
+++ b/src/libffmpeg/libavcodec/imgconvert_template.h
@@ -21,10 +21,11 @@
#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,
+static void glue(yuv420p_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
int width, int height)
{
- uint8_t *y1_ptr, *y2_ptr, *cb_ptr, *cr_ptr, *d, *d1, *d2;
+ const uint8_t *y1_ptr, *y2_ptr, *cb_ptr, *cr_ptr;
+ uint8_t *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;
@@ -114,10 +115,11 @@ static void glue(yuv420p_to_, RGB_NAME)(AVPicture *dst, AVPicture *src,
}
}
-static void glue(yuvj420p_to_, RGB_NAME)(AVPicture *dst, AVPicture *src,
+static void glue(yuvj420p_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
int width, int height)
{
- uint8_t *y1_ptr, *y2_ptr, *cb_ptr, *cr_ptr, *d, *d1, *d2;
+ const uint8_t *y1_ptr, *y2_ptr, *cb_ptr, *cr_ptr;
+ uint8_t *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;
@@ -207,7 +209,7 @@ static void glue(yuvj420p_to_, RGB_NAME)(AVPicture *dst, AVPicture *src,
}
}
-static void glue(RGB_NAME, _to_yuv420p)(AVPicture *dst, AVPicture *src,
+static void glue(RGB_NAME, _to_yuv420p)(AVPicture *dst, const AVPicture *src,
int width, int height)
{
int wrap, wrap3, width2;
@@ -314,7 +316,7 @@ static void glue(RGB_NAME, _to_yuv420p)(AVPicture *dst, AVPicture *src,
}
}
-static void glue(RGB_NAME, _to_gray)(AVPicture *dst, AVPicture *src,
+static void glue(RGB_NAME, _to_gray)(AVPicture *dst, const AVPicture *src,
int width, int height)
{
const unsigned char *p;
@@ -340,7 +342,7 @@ static void glue(RGB_NAME, _to_gray)(AVPicture *dst, AVPicture *src,
}
}
-static void glue(gray_to_, RGB_NAME)(AVPicture *dst, AVPicture *src,
+static void glue(gray_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
int width, int height)
{
const unsigned char *p;
@@ -366,7 +368,7 @@ static void glue(gray_to_, RGB_NAME)(AVPicture *dst, AVPicture *src,
}
}
-static void glue(pal8_to_, RGB_NAME)(AVPicture *dst, AVPicture *src,
+static void glue(pal8_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
int width, int height)
{
const unsigned char *p;
@@ -409,7 +411,7 @@ static void glue(pal8_to_, RGB_NAME)(AVPicture *dst, AVPicture *src,
#if !defined(FMT_RGBA32) && defined(RGBA_OUT)
/* alpha support */
-static void glue(rgba32_to_, RGB_NAME)(AVPicture *dst, AVPicture *src,
+static void glue(rgba32_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
int width, int height)
{
const uint8_t *s;
@@ -439,7 +441,7 @@ static void glue(rgba32_to_, RGB_NAME)(AVPicture *dst, AVPicture *src,
}
}
-static void glue(RGB_NAME, _to_rgba32)(AVPicture *dst, AVPicture *src,
+static void glue(RGB_NAME, _to_rgba32)(AVPicture *dst, const AVPicture *src,
int width, int height)
{
const uint8_t *s;
@@ -469,7 +471,7 @@ static void glue(RGB_NAME, _to_rgba32)(AVPicture *dst, AVPicture *src,
#ifndef FMT_RGB24
-static void glue(rgb24_to_, RGB_NAME)(AVPicture *dst, AVPicture *src,
+static void glue(rgb24_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
int width, int height)
{
const uint8_t *s;
@@ -497,7 +499,7 @@ static void glue(rgb24_to_, RGB_NAME)(AVPicture *dst, AVPicture *src,
}
}
-static void glue(RGB_NAME, _to_rgb24)(AVPicture *dst, AVPicture *src,
+static void glue(RGB_NAME, _to_rgb24)(AVPicture *dst, const AVPicture *src,
int width, int height)
{
const uint8_t *s;
@@ -529,10 +531,11 @@ static void glue(RGB_NAME, _to_rgb24)(AVPicture *dst, AVPicture *src,
#ifdef FMT_RGB24
-static void yuv444p_to_rgb24(AVPicture *dst, AVPicture *src,
+static void yuv444p_to_rgb24(AVPicture *dst, const AVPicture *src,
int width, int height)
{
- uint8_t *y1_ptr, *cb_ptr, *cr_ptr, *d, *d1;
+ const uint8_t *y1_ptr, *cb_ptr, *cr_ptr;
+ uint8_t *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;
@@ -561,10 +564,11 @@ static void yuv444p_to_rgb24(AVPicture *dst, AVPicture *src,
}
}
-static void yuvj444p_to_rgb24(AVPicture *dst, AVPicture *src,
+static void yuvj444p_to_rgb24(AVPicture *dst, const AVPicture *src,
int width, int height)
{
- uint8_t *y1_ptr, *cb_ptr, *cr_ptr, *d, *d1;
+ const uint8_t *y1_ptr, *cb_ptr, *cr_ptr;
+ uint8_t *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;
@@ -593,7 +597,7 @@ static void yuvj444p_to_rgb24(AVPicture *dst, AVPicture *src,
}
}
-static void rgb24_to_yuv444p(AVPicture *dst, AVPicture *src,
+static void rgb24_to_yuv444p(AVPicture *dst, const AVPicture *src,
int width, int height)
{
int src_wrap, x, y;
@@ -625,7 +629,7 @@ static void rgb24_to_yuv444p(AVPicture *dst, AVPicture *src,
}
}
-static void rgb24_to_yuvj420p(AVPicture *dst, AVPicture *src,
+static void rgb24_to_yuvj420p(AVPicture *dst, const AVPicture *src,
int width, int height)
{
int wrap, wrap3, width2;
@@ -732,7 +736,7 @@ static void rgb24_to_yuvj420p(AVPicture *dst, AVPicture *src,
}
}
-static void rgb24_to_yuvj444p(AVPicture *dst, AVPicture *src,
+static void rgb24_to_yuvj444p(AVPicture *dst, const AVPicture *src,
int width, int height)
{
int src_wrap, x, y;
@@ -768,7 +772,7 @@ static void rgb24_to_yuvj444p(AVPicture *dst, AVPicture *src,
#if defined(FMT_RGB24) || defined(FMT_RGBA32)
-static void glue(RGB_NAME, _to_pal8)(AVPicture *dst, AVPicture *src,
+static void glue(RGB_NAME, _to_pal8)(AVPicture *dst, const AVPicture *src,
int width, int height)
{
const unsigned char *p;
@@ -816,7 +820,8 @@ static void glue(RGB_NAME, _to_pal8)(AVPicture *dst, AVPicture *src,
#ifdef RGBA_IN
-static int glue(get_alpha_info_, RGB_NAME)(AVPicture *src, int width, int height)
+static int glue(get_alpha_info_, RGB_NAME)(const AVPicture *src,
+ int width, int height)
{
const unsigned char *p;
int src_wrap, ret, x, y;
diff --git a/src/libffmpeg/libavcodec/imgresample.c b/src/libffmpeg/libavcodec/imgresample.c
index 140894d36..a18645e33 100644
--- a/src/libffmpeg/libavcodec/imgresample.c
+++ b/src/libffmpeg/libavcodec/imgresample.c
@@ -58,11 +58,12 @@ static inline int get_phase(int pos)
}
/* This function must be optimized */
-static void h_resample_fast(uint8_t *dst, int dst_width, uint8_t *src, int src_width,
- int src_start, int src_incr, int16_t *filters)
+static void h_resample_fast(uint8_t *dst, int dst_width, const uint8_t *src,
+ int src_width, int src_start, int src_incr,
+ int16_t *filters)
{
int src_pos, phase, sum, i;
- uint8_t *s;
+ const uint8_t *s;
int16_t *filter;
src_pos = src_start;
@@ -101,11 +102,11 @@ static void h_resample_fast(uint8_t *dst, int dst_width, uint8_t *src, int src_w
}
/* This function must be optimized */
-static void v_resample(uint8_t *dst, int dst_width, uint8_t *src, int wrap,
- int16_t *filter)
+static void v_resample(uint8_t *dst, int dst_width, const uint8_t *src,
+ int wrap, int16_t *filter)
{
int sum, i;
- uint8_t *s;
+ const uint8_t *s;
s = src;
for(i=0;i<dst_width;i++) {
@@ -160,11 +161,12 @@ static void v_resample(uint8_t *dst, int dst_width, uint8_t *src, int wrap,
#define DUMP(reg) movq_r2m(reg, tmp); printf(#reg "=%016Lx\n", tmp.uq);
/* XXX: do four pixels at a time */
-static void h_resample_fast4_mmx(uint8_t *dst, int dst_width, uint8_t *src, int src_width,
+static void h_resample_fast4_mmx(uint8_t *dst, int dst_width,
+ const uint8_t *src, int src_width,
int src_start, int src_incr, int16_t *filters)
{
int src_pos, phase;
- uint8_t *s;
+ const uint8_t *s;
int16_t *filter;
mmx_t tmp;
@@ -204,11 +206,11 @@ static void h_resample_fast4_mmx(uint8_t *dst, int dst_width, uint8_t *src, int
emms();
}
-static void v_resample4_mmx(uint8_t *dst, int dst_width, uint8_t *src, int wrap,
- int16_t *filter)
+static void v_resample4_mmx(uint8_t *dst, int dst_width, const uint8_t *src,
+ int wrap, int16_t *filter)
{
int sum, i, v;
- uint8_t *s;
+ const uint8_t *s;
mmx_t tmp;
mmx_t coefs[4];
@@ -280,11 +282,11 @@ typedef union {
signed short s[8];
} vec_ss_t;
-void v_resample16_altivec(uint8_t *dst, int dst_width, uint8_t *src, int wrap,
- int16_t *filter)
+void v_resample16_altivec(uint8_t *dst, int dst_width, const uint8_t *src,
+ int wrap, int16_t *filter)
{
int sum, i;
- uint8_t *s;
+ const uint8_t *s;
vector unsigned char *tv, tmp, dstv, zero;
vec_ss_t srchv[4], srclv[4], fv[4];
vector signed short zeros, sumhv, sumlv;
@@ -397,11 +399,12 @@ void v_resample16_altivec(uint8_t *dst, int dst_width, uint8_t *src, int wrap,
#endif
/* slow version to handle limit cases. Does not need optimisation */
-static void h_resample_slow(uint8_t *dst, int dst_width, uint8_t *src, int src_width,
+static void h_resample_slow(uint8_t *dst, int dst_width,
+ const uint8_t *src, int src_width,
int src_start, int src_incr, int16_t *filters)
{
int src_pos, phase, sum, j, v, i;
- uint8_t *s, *src_end;
+ const uint8_t *s, *src_end;
int16_t *filter;
src_end = src + src_width;
@@ -432,8 +435,9 @@ static void h_resample_slow(uint8_t *dst, int dst_width, uint8_t *src, int src_w
}
}
-static void h_resample(uint8_t *dst, int dst_width, uint8_t *src, int src_width,
- int src_start, int src_incr, int16_t *filters)
+static void h_resample(uint8_t *dst, int dst_width, const uint8_t *src,
+ int src_width, int src_start, int src_incr,
+ int16_t *filters)
{
int n, src_end;
@@ -607,7 +611,7 @@ ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
}
void img_resample(ImgReSampleContext *s,
- AVPicture *output, AVPicture *input)
+ AVPicture *output, const AVPicture *input)
{
int i, shift;
diff --git a/src/libffmpeg/libavcodec/indeo3.c b/src/libffmpeg/libavcodec/indeo3.c
index 0cf411842..d377eb993 100644
--- a/src/libffmpeg/libavcodec/indeo3.c
+++ b/src/libffmpeg/libavcodec/indeo3.c
@@ -103,8 +103,8 @@ static void iv_alloc_frames(Indeo3DecodeContext *s)
int luma_width, luma_height, luma_pixels, chroma_width, chroma_height,
chroma_pixels, bufsize, i;
- luma_width = (s->width + 15) & -0x10;
- luma_height = (s->height + 15) & -0x10;
+ luma_width = (s->width + 3) & (~3);
+ luma_height = (s->height + 3) & (~3);
s->iv_frame[0].y_w = s->iv_frame[0].y_h =
s->iv_frame[0].the_buf_size = 0;
@@ -112,8 +112,8 @@ static void iv_alloc_frames(Indeo3DecodeContext *s)
s->iv_frame[1].the_buf_size = 0;
s->iv_frame[1].the_buf = NULL;
- chroma_width = luma_width >> 2;
- chroma_height = luma_height >> 2;
+ chroma_width = ((luma_width >> 2) + 3) & (~3);
+ chroma_height = ((luma_height>> 2) + 3) & (~3);
luma_pixels = luma_width * luma_height;
chroma_pixels = chroma_width * chroma_height;
@@ -306,8 +306,8 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s,
long *width_tbl, width_tbl_arr[10];
char *ref_vectors;
unsigned char *cur_frm_pos, *ref_frm_pos, *cp, *cp2;
- unsigned long *cur_lp, *ref_lp, *correction_lp[2], *correctionloworder_lp[2],
- *correctionhighorder_lp[2];
+ uint32_t *cur_lp, *ref_lp;
+ const uint32_t *correction_lp[2], *correctionloworder_lp[2], *correctionhighorder_lp[2];
unsigned short *correction_type_sp[2];
ustr_t strip_tbl[20], *strip;
int i, j, k, lp1, lp2, flag1, cmd, blks_width, blks_height, region_160_width,
@@ -399,7 +399,7 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s,
if(cmd == 0 || ref_vectors != NULL) {
for(lp1 = 0; lp1 < blks_width; lp1++) {
for(i = 0, j = 0; i < blks_height; i++, j += width_tbl[1])
- ((unsigned long *)cur_frm_pos)[j] = ((unsigned long *)ref_frm_pos)[j];
+ ((uint32_t *)cur_frm_pos)[j] = ((uint32_t *)ref_frm_pos)[j];
cur_frm_pos += 4;
ref_frm_pos += 4;
}
@@ -414,7 +414,10 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s,
if((lv - 8) <= 7 && (k == 0 || k == 3 || k == 10)) {
cp2 = s->ModPred + ((lv - 8) << 7);
cp = ref_frm_pos;
- for(i = 0; i < blks_width << 2; i++) { *(cp++) = cp2[*cp >> 1]; }
+ for(i = 0; i < blks_width << 2; i++) {
+ int v = *cp >> 1;
+ *(cp++) = cp2[v];
+ }
}
if(k == 1 || k == 4) {
@@ -438,8 +441,8 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s,
for(lp1 = 0; lp1 < blks_width; lp1++) {
for(lp2 = 0; lp2 < 4; ) {
k = *buf1++;
- cur_lp = ((unsigned long *)cur_frm_pos) + width_tbl[lp2];
- ref_lp = ((unsigned long *)ref_frm_pos) + width_tbl[lp2];
+ cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2];
+ ref_lp = ((uint32_t *)ref_frm_pos) + width_tbl[lp2];
switch(correction_type_sp[0][k]) {
case 0:
@@ -540,8 +543,8 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s,
for(lp2 = 0; lp2 < 4; ) {
k = *buf1++;
- cur_lp = ((unsigned long *)cur_frm_pos) + width_tbl[lp2 * 2];
- ref_lp = ((unsigned long *)cur_frm_pos) + width_tbl[(lp2 * 2) - 1];
+ cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2 * 2];
+ ref_lp = ((uint32_t *)cur_frm_pos) + width_tbl[(lp2 * 2) - 1];
switch(correction_type_sp[lp2 & 0x01][k]) {
case 0:
@@ -652,8 +655,8 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s,
for(lp1 = 0; lp1 < blks_width; lp1 += 2) {
for(lp2 = 0; lp2 < 4; ) {
k = *buf1++;
- cur_lp = ((unsigned long *)cur_frm_pos) + width_tbl[lp2 * 2];
- ref_lp = ((unsigned long *)cur_frm_pos) + width_tbl[(lp2 * 2) - 1];
+ cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2 * 2];
+ ref_lp = ((uint32_t *)cur_frm_pos) + width_tbl[(lp2 * 2) - 1];
lv1 = ref_lp[0];
lv2 = ref_lp[1];
if(lp2 == 0 && flag1 != 0) {
@@ -814,8 +817,8 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s,
for(lp1 = 0; lp1 < blks_width; lp1 += 2) {
for(lp2 = 0; lp2 < 4; ) {
k = *buf1++;
- cur_lp = ((unsigned long *)cur_frm_pos) + width_tbl[lp2 * 2];
- ref_lp = ((unsigned long *)ref_frm_pos) + width_tbl[lp2 * 2];
+ cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2 * 2];
+ ref_lp = ((uint32_t *)ref_frm_pos) + width_tbl[lp2 * 2];
switch(correction_type_sp[lp2 & 0x01][k]) {
case 0:
@@ -862,8 +865,8 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s,
if(lp2 == 0) {
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];
+ ((uint32_t *)cur_frm_pos)[j] = ((uint32_t *)ref_frm_pos)[j];
+ ((uint32_t *)cur_frm_pos)[j+1] = ((uint32_t *)ref_frm_pos)[j+1];
}
RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2)
break;
@@ -890,7 +893,7 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s,
lv += (lv << 8);
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;
+ ((uint32_t *)cur_frm_pos)[j] = ((uint32_t *)cur_frm_pos)[j+1] = lv;
LV1_CHECK(buf1,rle_v3,lv1,lp2)
break;
@@ -917,8 +920,8 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s,
for(lp1 = 0; lp1 < blks_width; lp1++) {
for(lp2 = 0; lp2 < 4; ) {
k = *buf1++;
- cur_lp = ((unsigned long *)cur_frm_pos) + width_tbl[lp2 * 2];
- ref_lp = ((unsigned long *)ref_frm_pos) + width_tbl[lp2 * 2];
+ cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2 * 2];
+ ref_lp = ((uint32_t *)ref_frm_pos) + width_tbl[lp2 * 2];
switch(correction_type_sp[lp2 & 0x01][k]) {
case 0:
diff --git a/src/libffmpeg/libavcodec/indeo3data.h b/src/libffmpeg/libavcodec/indeo3data.h
index fd59f712b..47549268d 100644
--- a/src/libffmpeg/libavcodec/indeo3data.h
+++ b/src/libffmpeg/libavcodec/indeo3data.h
@@ -1,5 +1,5 @@
-unsigned long correction[] = {
+static const uint32_t correction[] = {
0x00000000, 0x00000202, 0xfffffdfe, 0x000002ff, 0xfffffd01, 0xffffff03, 0x000000fd, 0x00000404,
0xfffffbfc, 0x00000501, 0xfffffaff, 0x00000105, 0xfffffefb, 0x000003fc, 0xfffffc04, 0x000005fe,
0xfffffa02, 0xfffffe06, 0x000001fa, 0x00000904, 0xfffff6fc, 0x00000409, 0xfffffbf7, 0x00000909,
@@ -771,7 +771,7 @@ unsigned long correction[] = {
};
-unsigned long correctionloworder[] = {
+static const uint32_t correctionloworder[] = {
0x00000000, 0x02020202, 0xfdfdfdfe, 0x0302feff, 0xfcfd0101, 0xfeff0303, 0x0100fcfd, 0x04040404,
0xfbfbfbfc, 0x05050101, 0xfafafeff, 0x01010505, 0xfefefafb, 0x0403fbfc, 0xfbfc0404, 0x0605fdfe,
0xf9fa0202, 0xfdfe0606, 0x0201f9fa, 0x09090404, 0xf6f6fbfc, 0x04040909, 0xfbfbf6f7, 0x09090909,
@@ -1543,7 +1543,7 @@ unsigned long correctionloworder[] = {
};
-unsigned long correctionhighorder[] = {
+static const uint32_t correctionhighorder[] = {
0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef,
0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef,
0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef,
diff --git a/src/libffmpeg/libavcodec/interplayvideo.c b/src/libffmpeg/libavcodec/interplayvideo.c
new file mode 100644
index 000000000..a8a7c0f56
--- /dev/null
+++ b/src/libffmpeg/libavcodec/interplayvideo.c
@@ -0,0 +1,976 @@
+/*
+ * Interplay MVE Video Decoder
+ * 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
+ *
+ */
+
+/**
+ * @file interplayvideo.c
+ * Interplay MVE Video Decoder by Mike Melanson (melanson@pcisys.net)
+ * For more information about the Interplay MVE format, visit:
+ * http://www.pcisys.net/~melanson/codecs/interplay-mve.txt
+ * This code is written in such a way that the identifiers match up
+ * with the encoding descriptions in the document.
+ *
+ * This decoder presently only supports a PAL8 output colorspace.
+ *
+ * An Interplay video frame consists of 2 parts: The decoding map and
+ * the video data. A demuxer must load these 2 parts together in a single
+ * buffer before sending it through the stream to this decoder.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "common.h"
+#include "avcodec.h"
+#include "dsputil.h"
+
+#define PALETTE_COUNT 256
+
+/* debugging support */
+#define DEBUG_INTERPLAY 0
+#if DEBUG_INTERPLAY
+#define debug_interplay printf
+#else
+static inline void debug_interplay(const char *format, ...) { }
+#endif
+
+typedef struct IpvideoContext {
+
+ AVCodecContext *avctx;
+ DSPContext dsp;
+ AVFrame second_last_frame;
+ AVFrame last_frame;
+ AVFrame current_frame;
+ unsigned char *decoding_map;
+ int decoding_map_size;
+
+ unsigned char *buf;
+ int size;
+
+ unsigned char palette[PALETTE_COUNT * 4];
+
+ unsigned char *stream_ptr;
+ unsigned char *stream_end;
+ unsigned char *pixel_ptr;
+ int line_inc;
+ int stride;
+ int upper_motion_limit_offset;
+
+} IpvideoContext;
+
+#define CHECK_STREAM_PTR(n) \
+ if ((s->stream_ptr + n) > s->stream_end) { \
+ printf ("Interplay video warning: stream_ptr out of bounds (%p >= %p)\n", \
+ s->stream_ptr + n, s->stream_end); \
+ return -1; \
+ }
+
+static void ipvideo_new_palette(IpvideoContext *s, unsigned char *palette) {
+
+ int i;
+ unsigned char r, g, b;
+ unsigned int *palette32;
+
+ palette32 = (unsigned int *)s->palette;
+ for (i = 0; i < PALETTE_COUNT; i++) {
+ r = *palette++;
+ g = *palette++;
+ b = *palette++;
+ palette32[i] = (r << 16) | (g << 8) | (b);
+ }
+}
+
+#define COPY_FROM_CURRENT() \
+ motion_offset = current_offset; \
+ motion_offset += y * s->stride; \
+ motion_offset += x; \
+ if (motion_offset < 0) { \
+ printf (" Interplay video: motion offset < 0 (%d)\n", motion_offset); \
+ return -1; \
+ } else if (motion_offset > s->upper_motion_limit_offset) { \
+ printf (" Interplay video: motion offset above limit (%d >= %d)\n", \
+ motion_offset, s->upper_motion_limit_offset); \
+ return -1; \
+ } \
+ s->dsp.put_pixels_tab[0][0](s->pixel_ptr, \
+ s->current_frame.data[0] + motion_offset, s->stride, 8);
+
+#define COPY_FROM_PREVIOUS() \
+ motion_offset = current_offset; \
+ motion_offset += y * s->stride; \
+ motion_offset += x; \
+ if (motion_offset < 0) { \
+ printf (" Interplay video: motion offset < 0 (%d)\n", motion_offset); \
+ return -1; \
+ } else if (motion_offset > s->upper_motion_limit_offset) { \
+ printf (" Interplay video: motion offset above limit (%d >= %d)\n", \
+ motion_offset, s->upper_motion_limit_offset); \
+ return -1; \
+ } \
+ s->dsp.put_pixels_tab[0][0](s->pixel_ptr, \
+ s->last_frame.data[0] + motion_offset, s->stride, 8);
+
+#define COPY_FROM_SECOND_LAST() \
+ motion_offset = current_offset; \
+ motion_offset += y * s->stride; \
+ motion_offset += x; \
+ if (motion_offset < 0) { \
+ printf (" Interplay video: motion offset < 0 (%d)\n", motion_offset); \
+ return -1; \
+ } else if (motion_offset > s->upper_motion_limit_offset) { \
+ printf (" Interplay video: motion offset above limit (%d >= %d)\n", \
+ motion_offset, s->upper_motion_limit_offset); \
+ return -1; \
+ } \
+ s->dsp.put_pixels_tab[0][0](s->pixel_ptr, \
+ s->second_last_frame.data[0] + motion_offset, s->stride, 8);
+
+static int ipvideo_decode_block_opcode_0x0(IpvideoContext *s)
+{
+ int x, y;
+ int motion_offset;
+ int current_offset = s->pixel_ptr - s->current_frame.data[0];
+
+ /* copy a block from the previous frame */
+ x = y = 0;
+ COPY_FROM_PREVIOUS();
+
+ /* report success */
+ return 0;
+}
+
+static int ipvideo_decode_block_opcode_0x1(IpvideoContext *s)
+{
+ int x, y;
+ int motion_offset;
+ int current_offset = s->pixel_ptr - s->current_frame.data[0];
+
+ /* copy block from 2 frames ago */
+ x = y = 0;
+ COPY_FROM_SECOND_LAST();
+
+ /* report success */
+ return 0;
+}
+
+static int ipvideo_decode_block_opcode_0x2(IpvideoContext *s)
+{
+ unsigned char B;
+ int x, y;
+ int motion_offset;
+ int current_offset = s->pixel_ptr - s->current_frame.data[0];
+
+ /* copy block from 2 frames ago using a motion vector; need 1 more byte */
+ CHECK_STREAM_PTR(1);
+ B = *s->stream_ptr++;
+
+ if (B < 56) {
+ x = 8 + (B % 7);
+ y = B / 7;
+ } else {
+ x = -14 + ((B - 56) % 29);
+ y = 8 + ((B - 56) / 29);
+ }
+
+ debug_interplay (" motion byte = %d, (x, y) = (%d, %d)\n", B, x, y);
+ COPY_FROM_SECOND_LAST();
+
+ /* report success */
+ return 0;
+}
+
+static int ipvideo_decode_block_opcode_0x3(IpvideoContext *s)
+{
+ unsigned char B;
+ int x, y;
+ int motion_offset;
+ int current_offset = s->pixel_ptr - s->current_frame.data[0];
+
+ /* copy 8x8 block from current frame from an up/left block */
+
+ /* need 1 more byte for motion */
+ CHECK_STREAM_PTR(1);
+ B = *s->stream_ptr++;
+
+ if (B < 56) {
+ x = -(8 + (B % 7));
+ y = -(B / 7);
+ } else {
+ x = -(-14 + ((B - 56) % 29));
+ y = -( 8 + ((B - 56) / 29));
+ }
+
+ debug_interplay (" motion byte = %d, (x, y) = (%d, %d)\n", B, x, y);
+ COPY_FROM_CURRENT();
+
+ /* report success */
+ return 0;
+}
+
+static int ipvideo_decode_block_opcode_0x4(IpvideoContext *s)
+{
+ int x, y;
+ unsigned char B, BL, BH;
+ int motion_offset;
+ int current_offset = s->pixel_ptr - s->current_frame.data[0];
+
+ /* copy a block from the previous frame; need 1 more byte */
+ CHECK_STREAM_PTR(1);
+
+ B = *s->stream_ptr++;
+ BL = B & 0x0F;
+ BH = (B >> 4) & 0x0F;
+ x = -8 + BL;
+ y = -8 + BH;
+
+ debug_interplay (" motion byte = %d, (x, y) = (%d, %d)\n", B, x, y);
+ COPY_FROM_PREVIOUS();
+
+ /* report success */
+ return 0;
+}
+
+static int ipvideo_decode_block_opcode_0x5(IpvideoContext *s)
+{
+ signed char x, y;
+ int motion_offset;
+ int current_offset = s->pixel_ptr - s->current_frame.data[0];
+
+ /* copy a block from the previous frame using an expanded range;
+ * need 2 more bytes */
+ CHECK_STREAM_PTR(2);
+
+ x = *s->stream_ptr++;
+ y = *s->stream_ptr++;
+
+ debug_interplay (" motion bytes = %d, %d\n", x, y);
+ COPY_FROM_PREVIOUS();
+
+ /* report success */
+ return 0;
+}
+
+static int ipvideo_decode_block_opcode_0x6(IpvideoContext *s)
+{
+ /* mystery opcode? skip multiple blocks? */
+ printf (" Interplay video: Help! Mystery opcode 0x6 seen\n");
+
+ /* report success */
+ return 0;
+}
+
+static int ipvideo_decode_block_opcode_0x7(IpvideoContext *s)
+{
+ int x, y;
+ unsigned char P0, P1;
+ unsigned char B[8];
+ unsigned int flags;
+ int bitmask;
+
+ /* 2-color encoding */
+ CHECK_STREAM_PTR(2);
+
+ P0 = *s->stream_ptr++;
+ P1 = *s->stream_ptr++;
+
+ if (P0 <= P1) {
+
+ /* need 8 more bytes from the stream */
+ CHECK_STREAM_PTR(8);
+ for (y = 0; y < 8; y++)
+ B[y] = *s->stream_ptr++;
+
+ for (y = 0; y < 8; y++) {
+ flags = B[y];
+ for (x = 0x01; x <= 0x80; x <<= 1) {
+ if (flags & x)
+ *s->pixel_ptr++ = P1;
+ else
+ *s->pixel_ptr++ = P0;
+ }
+ s->pixel_ptr += s->line_inc;
+ }
+
+ } else {
+
+ /* need 2 more bytes from the stream */
+ CHECK_STREAM_PTR(2);
+ B[0] = *s->stream_ptr++;
+ B[1] = *s->stream_ptr++;
+
+ flags = (B[1] << 8) | B[0];
+ bitmask = 0x0001;
+ for (y = 0; y < 8; y += 2) {
+ for (x = 0; x < 8; x += 2, bitmask <<= 1) {
+ if (flags & bitmask) {
+ *(s->pixel_ptr + x) = P1;
+ *(s->pixel_ptr + x + 1) = P1;
+ *(s->pixel_ptr + s->stride + x) = P1;
+ *(s->pixel_ptr + s->stride + x + 1) = P1;
+ } else {
+ *(s->pixel_ptr + x) = P0;
+ *(s->pixel_ptr + x + 1) = P0;
+ *(s->pixel_ptr + s->stride + x) = P0;
+ *(s->pixel_ptr + s->stride + x + 1) = P0;
+ }
+ }
+ s->pixel_ptr += s->stride * 2;
+ }
+ }
+
+ /* report success */
+ return 0;
+}
+
+static int ipvideo_decode_block_opcode_0x8(IpvideoContext *s)
+{
+ int x, y;
+ unsigned char P[8];
+ unsigned char B[8];
+ unsigned int flags = 0;
+ unsigned int bitmask = 0;
+ unsigned char P0 = 0, P1 = 0;
+ int lower_half = 0;
+
+ /* 2-color encoding for each 4x4 quadrant, or 2-color encoding on
+ * either top and bottom or left and right halves */
+ CHECK_STREAM_PTR(2);
+
+ P[0] = *s->stream_ptr++;
+ P[1] = *s->stream_ptr++;
+
+ if (P[0] <= P[1]) {
+
+ /* need 12 more bytes */
+ CHECK_STREAM_PTR(12);
+ B[0] = *s->stream_ptr++; B[1] = *s->stream_ptr++;
+ P[2] = *s->stream_ptr++; P[3] = *s->stream_ptr++;
+ B[2] = *s->stream_ptr++; B[3] = *s->stream_ptr++;
+ P[4] = *s->stream_ptr++; P[5] = *s->stream_ptr++;
+ B[4] = *s->stream_ptr++; B[5] = *s->stream_ptr++;
+ P[6] = *s->stream_ptr++; P[7] = *s->stream_ptr++;
+ B[6] = *s->stream_ptr++; B[7] = *s->stream_ptr++;
+
+ for (y = 0; y < 8; y++) {
+
+ /* time to reload flags? */
+ if (y == 0) {
+ flags =
+ ((B[0] & 0xF0) << 4) | ((B[4] & 0xF0) << 8) |
+ ((B[0] & 0x0F) ) | ((B[4] & 0x0F) << 4) |
+ ((B[1] & 0xF0) << 20) | ((B[5] & 0xF0) << 24) |
+ ((B[1] & 0x0F) << 16) | ((B[5] & 0x0F) << 20);
+ bitmask = 0x00000001;
+ lower_half = 0; /* still on top half */
+ } else if (y == 4) {
+ flags =
+ ((B[2] & 0xF0) << 4) | ((B[6] & 0xF0) << 8) |
+ ((B[2] & 0x0F) ) | ((B[6] & 0x0F) << 4) |
+ ((B[3] & 0xF0) << 20) | ((B[7] & 0xF0) << 24) |
+ ((B[3] & 0x0F) << 16) | ((B[7] & 0x0F) << 20);
+ bitmask = 0x00000001;
+ lower_half = 2;
+ }
+
+ for (x = 0; x < 8; x++, bitmask <<= 1) {
+ /* get the pixel values ready for this quadrant */
+ if (x == 0) {
+ P0 = P[lower_half + 0];
+ P1 = P[lower_half + 1];
+ } else if (x == 4) {
+ P0 = P[lower_half + 4];
+ P1 = P[lower_half + 5];
+ }
+
+ if (flags & bitmask)
+ *s->pixel_ptr++ = P1;
+ else
+ *s->pixel_ptr++ = P0;
+ }
+ s->pixel_ptr += s->line_inc;
+ }
+
+ } else {
+
+ /* need 10 more bytes */
+ CHECK_STREAM_PTR(10);
+ B[0] = *s->stream_ptr++; B[1] = *s->stream_ptr++;
+ B[2] = *s->stream_ptr++; B[3] = *s->stream_ptr++;
+ P[2] = *s->stream_ptr++; P[3] = *s->stream_ptr++;
+ B[4] = *s->stream_ptr++; B[5] = *s->stream_ptr++;
+ B[6] = *s->stream_ptr++; B[7] = *s->stream_ptr++;
+
+ if (P[2] <= P[3]) {
+
+ /* vertical split; left & right halves are 2-color encoded */
+
+ for (y = 0; y < 8; y++) {
+
+ /* time to reload flags? */
+ if (y == 0) {
+ flags =
+ ((B[0] & 0xF0) << 4) | ((B[4] & 0xF0) << 8) |
+ ((B[0] & 0x0F) ) | ((B[4] & 0x0F) << 4) |
+ ((B[1] & 0xF0) << 20) | ((B[5] & 0xF0) << 24) |
+ ((B[1] & 0x0F) << 16) | ((B[5] & 0x0F) << 20);
+ bitmask = 0x00000001;
+ } else if (y == 4) {
+ flags =
+ ((B[2] & 0xF0) << 4) | ((B[6] & 0xF0) << 8) |
+ ((B[2] & 0x0F) ) | ((B[6] & 0x0F) << 4) |
+ ((B[3] & 0xF0) << 20) | ((B[7] & 0xF0) << 24) |
+ ((B[3] & 0x0F) << 16) | ((B[7] & 0x0F) << 20);
+ bitmask = 0x00000001;
+ }
+
+ for (x = 0; x < 8; x++, bitmask <<= 1) {
+ /* get the pixel values ready for this half */
+ if (x == 0) {
+ P0 = P[0];
+ P1 = P[1];
+ } else if (x == 4) {
+ P0 = P[2];
+ P1 = P[3];
+ }
+
+ if (flags & bitmask)
+ *s->pixel_ptr++ = P1;
+ else
+ *s->pixel_ptr++ = P0;
+ }
+ s->pixel_ptr += s->line_inc;
+ }
+
+ } else {
+
+ /* horizontal split; top & bottom halves are 2-color encoded */
+
+ for (y = 0; y < 8; y++) {
+
+ flags = B[y];
+ if (y == 0) {
+ P0 = P[0];
+ P1 = P[1];
+ } else if (y == 4) {
+ P0 = P[2];
+ P1 = P[3];
+ }
+
+ for (bitmask = 0x01; bitmask <= 0x80; bitmask <<= 1) {
+
+ if (flags & bitmask)
+ *s->pixel_ptr++ = P1;
+ else
+ *s->pixel_ptr++ = P0;
+ }
+ s->pixel_ptr += s->line_inc;
+ }
+ }
+ }
+
+ /* report success */
+ return 0;
+}
+
+static int ipvideo_decode_block_opcode_0x9(IpvideoContext *s)
+{
+ int x, y;
+ unsigned char P[4];
+ unsigned char B[4];
+ unsigned int flags = 0;
+ int shifter = 0;
+ unsigned char pix;
+
+ /* 4-color encoding */
+ CHECK_STREAM_PTR(4);
+
+ for (y = 0; y < 4; y++)
+ P[y] = *s->stream_ptr++;
+
+ if ((P[0] <= P[1]) && (P[2] <= P[3])) {
+
+ /* 1 of 4 colors for each pixel, need 16 more bytes */
+ CHECK_STREAM_PTR(16);
+
+ for (y = 0; y < 8; y++) {
+ /* get the next set of 8 2-bit flags */
+ flags = (s->stream_ptr[1] << 8) | s->stream_ptr[0];
+ s->stream_ptr += 2;
+ for (x = 0, shifter = 0; x < 8; x++, shifter += 2) {
+ *s->pixel_ptr++ = P[(flags >> shifter) & 0x03];
+ }
+ s->pixel_ptr += s->line_inc;
+ }
+
+ } else if ((P[0] <= P[1]) && (P[2] > P[3])) {
+
+ /* 1 of 4 colors for each 2x2 block, need 4 more bytes */
+ CHECK_STREAM_PTR(4);
+
+ B[0] = *s->stream_ptr++;
+ B[1] = *s->stream_ptr++;
+ B[2] = *s->stream_ptr++;
+ B[3] = *s->stream_ptr++;
+ flags = (B[3] << 24) | (B[2] << 16) | (B[1] << 8) | B[0];
+ shifter = 0;
+
+ for (y = 0; y < 8; y += 2) {
+ for (x = 0; x < 8; x += 2, shifter += 2) {
+ pix = P[(flags >> shifter) & 0x03];
+ *(s->pixel_ptr + x) = pix;
+ *(s->pixel_ptr + x + 1) = pix;
+ *(s->pixel_ptr + s->stride + x) = pix;
+ *(s->pixel_ptr + s->stride + x + 1) = pix;
+ }
+ s->pixel_ptr += s->stride * 2;
+ }
+
+ } else if ((P[0] > P[1]) && (P[2] <= P[3])) {
+
+ /* 1 of 4 colors for each 2x1 block, need 8 more bytes */
+ CHECK_STREAM_PTR(8);
+
+ for (y = 0; y < 8; y++) {
+ /* time to reload flags? */
+ if ((y == 0) || (y == 4)) {
+ B[0] = *s->stream_ptr++;
+ B[1] = *s->stream_ptr++;
+ B[2] = *s->stream_ptr++;
+ B[3] = *s->stream_ptr++;
+ flags = (B[3] << 24) | (B[2] << 16) | (B[1] << 8) | B[0];
+ shifter = 0;
+ }
+ for (x = 0; x < 8; x += 2, shifter += 2) {
+ pix = P[(flags >> shifter) & 0x03];
+ *(s->pixel_ptr + x) = pix;
+ *(s->pixel_ptr + x + 1) = pix;
+ }
+ s->pixel_ptr += s->stride;
+ }
+
+ } else {
+
+ /* 1 of 4 colors for each 1x2 block, need 8 more bytes */
+ CHECK_STREAM_PTR(8);
+
+ for (y = 0; y < 8; y += 2) {
+ /* time to reload flags? */
+ if ((y == 0) || (y == 4)) {
+ B[0] = *s->stream_ptr++;
+ B[1] = *s->stream_ptr++;
+ B[2] = *s->stream_ptr++;
+ B[3] = *s->stream_ptr++;
+ flags = (B[3] << 24) | (B[2] << 16) | (B[1] << 8) | B[0];
+ shifter = 0;
+ }
+ for (x = 0; x < 8; x++, shifter += 2) {
+ pix = P[(flags >> shifter) & 0x03];
+ *(s->pixel_ptr + x) = pix;
+ *(s->pixel_ptr + s->stride + x) = pix;
+ }
+ s->pixel_ptr += s->stride * 2;
+ }
+ }
+
+ /* report success */
+ return 0;
+}
+
+static int ipvideo_decode_block_opcode_0xA(IpvideoContext *s)
+{
+ int x, y;
+ unsigned char P[16];
+ unsigned char B[16];
+ int flags = 0;
+ int shifter = 0;
+ int index;
+ int split;
+ int lower_half;
+
+ /* 4-color encoding for each 4x4 quadrant, or 4-color encoding on
+ * either top and bottom or left and right halves */
+ CHECK_STREAM_PTR(4);
+
+ for (y = 0; y < 4; y++)
+ P[y] = *s->stream_ptr++;
+
+ if (P[0] <= P[1]) {
+
+ /* 4-color encoding for each quadrant; need 28 more bytes */
+ CHECK_STREAM_PTR(28);
+
+ for (y = 0; y < 4; y++)
+ B[y] = *s->stream_ptr++;
+ for (y = 4; y < 16; y += 4) {
+ for (x = y; x < y + 4; x++)
+ P[x] = *s->stream_ptr++;
+ for (x = y; x < y + 4; x++)
+ B[x] = *s->stream_ptr++;
+ }
+
+ for (y = 0; y < 8; y++) {
+
+ lower_half = (y >= 4) ? 4 : 0;
+ flags = (B[y + 8] << 8) | B[y];
+
+ for (x = 0, shifter = 0; x < 8; x++, shifter += 2) {
+ split = (x >= 4) ? 8 : 0;
+ index = split + lower_half + ((flags >> shifter) & 0x03);
+ *s->pixel_ptr++ = P[index];
+ }
+
+ s->pixel_ptr += s->line_inc;
+ }
+
+ } else {
+
+ /* 4-color encoding for either left and right or top and bottom
+ * halves; need 20 more bytes */
+ CHECK_STREAM_PTR(20);
+
+ for (y = 0; y < 8; y++)
+ B[y] = *s->stream_ptr++;
+ for (y = 4; y < 8; y++)
+ P[y] = *s->stream_ptr++;
+ for (y = 8; y < 16; y++)
+ B[y] = *s->stream_ptr++;
+
+ if (P[4] <= P[5]) {
+
+ /* block is divided into left and right halves */
+ for (y = 0; y < 8; y++) {
+
+ flags = (B[y + 8] << 8) | B[y];
+ split = 0;
+
+ for (x = 0, shifter = 0; x < 8; x++, shifter += 2) {
+ if (x == 4)
+ split = 4;
+ *s->pixel_ptr++ = P[split + ((flags >> shifter) & 0x03)];
+ }
+
+ s->pixel_ptr += s->line_inc;
+ }
+
+ } else {
+
+ /* block is divided into top and bottom halves */
+ split = 0;
+ for (y = 0; y < 8; y++) {
+
+ flags = (B[y * 2 + 1] << 8) | B[y * 2];
+ if (y == 4)
+ split = 4;
+
+ for (x = 0, shifter = 0; x < 8; x++, shifter += 2)
+ *s->pixel_ptr++ = P[split + ((flags >> shifter) & 0x03)];
+
+ s->pixel_ptr += s->line_inc;
+ }
+ }
+ }
+
+ /* report success */
+ return 0;
+}
+
+static int ipvideo_decode_block_opcode_0xB(IpvideoContext *s)
+{
+ int x, y;
+
+ /* 64-color encoding (each pixel in block is a different color) */
+ CHECK_STREAM_PTR(64);
+
+ for (y = 0; y < 8; y++) {
+ for (x = 0; x < 8; x++) {
+ *s->pixel_ptr++ = *s->stream_ptr++;
+ }
+ s->pixel_ptr += s->line_inc;
+ }
+
+ /* report success */
+ return 0;
+}
+
+static int ipvideo_decode_block_opcode_0xC(IpvideoContext *s)
+{
+ int x, y;
+ unsigned char pix;
+
+ /* 16-color block encoding: each 2x2 block is a different color */
+ CHECK_STREAM_PTR(16);
+
+ for (y = 0; y < 8; y += 2) {
+ for (x = 0; x < 8; x += 2) {
+ pix = *s->stream_ptr++;
+ *(s->pixel_ptr + x) = pix;
+ *(s->pixel_ptr + x + 1) = pix;
+ *(s->pixel_ptr + s->stride + x) = pix;
+ *(s->pixel_ptr + s->stride + x + 1) = pix;
+ }
+ s->pixel_ptr += s->stride * 2;
+ }
+
+ /* report success */
+ return 0;
+}
+
+static int ipvideo_decode_block_opcode_0xD(IpvideoContext *s)
+{
+ int x, y;
+ unsigned char P[4];
+ unsigned char index = 0;
+
+ /* 4-color block encoding: each 4x4 block is a different color */
+ CHECK_STREAM_PTR(4);
+
+ for (y = 0; y < 4; y++)
+ P[y] = *s->stream_ptr++;
+
+ for (y = 0; y < 8; y++) {
+ if (y < 4)
+ index = 0;
+ else
+ index = 2;
+
+ for (x = 0; x < 8; x++) {
+ if (x == 4)
+ index++;
+ *s->pixel_ptr++ = P[index];
+ }
+ s->pixel_ptr += s->line_inc;
+ }
+
+ /* report success */
+ return 0;
+}
+
+static int ipvideo_decode_block_opcode_0xE(IpvideoContext *s)
+{
+ int x, y;
+ unsigned char pix;
+
+ /* 1-color encoding: the whole block is 1 solid color */
+ CHECK_STREAM_PTR(1);
+ pix = *s->stream_ptr++;
+
+ for (y = 0; y < 8; y++) {
+ for (x = 0; x < 8; x++) {
+ *s->pixel_ptr++ = pix;
+ }
+ s->pixel_ptr += s->line_inc;
+ }
+
+ /* report success */
+ return 0;
+}
+
+static int ipvideo_decode_block_opcode_0xF(IpvideoContext *s)
+{
+ int x, y;
+ unsigned char sample0, sample1;
+
+ /* dithered encoding */
+ CHECK_STREAM_PTR(2);
+ sample0 = *s->stream_ptr++;
+ sample1 = *s->stream_ptr++;
+
+ for (y = 0; y < 8; y++) {
+ for (x = 0; x < 8; x += 2) {
+ if (y & 1) {
+ *s->pixel_ptr++ = sample1;
+ *s->pixel_ptr++ = sample0;
+ } else {
+ *s->pixel_ptr++ = sample0;
+ *s->pixel_ptr++ = sample1;
+ }
+ }
+ s->pixel_ptr += s->line_inc;
+ }
+
+ /* report success */
+ return 0;
+}
+
+static int (*ipvideo_decode_block[16])(IpvideoContext *s);
+
+static void ipvideo_decode_opcodes(IpvideoContext *s)
+{
+ int x, y;
+ int index = 0;
+ unsigned char opcode;
+ int ret;
+ int code_counts[16];
+ static int frame = 0;
+
+ debug_interplay("------------------ frame %d\n", frame);
+ frame++;
+
+ for (x = 0; x < 16; x++)
+ code_counts[x] = 0;
+
+ /* this is PAL8, so make the palette available */
+ memcpy(s->current_frame.data[1], s->palette, PALETTE_COUNT * 4);
+
+ s->stride = s->current_frame.linesize[0];
+ s->stream_ptr = s->buf + 14; /* data starts 14 bytes in */
+ s->stream_end = s->buf + s->size;
+ s->line_inc = s->stride - 8;
+ s->upper_motion_limit_offset = (s->avctx->height - 8) * s->stride
+ + s->avctx->width - 8;
+ s->dsp = s->dsp;
+
+ for (y = 0; y < (s->stride * s->avctx->height); y += s->stride * 8) {
+ for (x = y; x < y + s->avctx->width; x += 8) {
+ /* bottom nibble first, then top nibble (which makes it
+ * hard to use a GetBitcontext) */
+ if (index & 1)
+ opcode = s->decoding_map[index >> 1] >> 4;
+ else
+ opcode = s->decoding_map[index >> 1] & 0xF;
+ index++;
+
+ debug_interplay(" block @ (%3d, %3d): encoding 0x%X, data ptr @ %p\n",
+ x - y, y / s->stride, opcode, s->stream_ptr);
+ code_counts[opcode]++;
+
+ s->pixel_ptr = s->current_frame.data[0] + x;
+ ret = ipvideo_decode_block[opcode](s);
+ if (ret != 0) {
+ printf(" Interplay video: decode problem on frame %d, @ block (%d, %d)\n",
+ frame, x - y, y / s->stride);
+ return;
+ }
+ }
+ }
+ if ((s->stream_ptr != s->stream_end) &&
+ (s->stream_ptr + 1 != s->stream_end)) {
+ printf (" Interplay video: decode finished with %d bytes left over\n",
+ s->stream_end - s->stream_ptr);
+ }
+}
+
+static int ipvideo_decode_init(AVCodecContext *avctx)
+{
+ IpvideoContext *s = avctx->priv_data;
+
+ s->avctx = avctx;
+
+ if (s->avctx->extradata_size != sizeof(AVPaletteControl)) {
+ printf (" Interplay video: expected extradata_size of %d\n",
+ (int)sizeof(AVPaletteControl));
+ return -1;
+ }
+
+ avctx->pix_fmt = PIX_FMT_PAL8;
+ avctx->has_b_frames = 0;
+ dsputil_init(&s->dsp, avctx);
+
+ /* decoding map contains 4 bits of information per 8x8 block */
+ s->decoding_map_size = avctx->width * avctx->height / (8 * 8 * 2);
+
+ /* assign block decode functions */
+ ipvideo_decode_block[0x0] = ipvideo_decode_block_opcode_0x0;
+ ipvideo_decode_block[0x1] = ipvideo_decode_block_opcode_0x1;
+ ipvideo_decode_block[0x2] = ipvideo_decode_block_opcode_0x2;
+ ipvideo_decode_block[0x3] = ipvideo_decode_block_opcode_0x3;
+ ipvideo_decode_block[0x4] = ipvideo_decode_block_opcode_0x4;
+ ipvideo_decode_block[0x5] = ipvideo_decode_block_opcode_0x5;
+ ipvideo_decode_block[0x6] = ipvideo_decode_block_opcode_0x6;
+ ipvideo_decode_block[0x7] = ipvideo_decode_block_opcode_0x7;
+ ipvideo_decode_block[0x8] = ipvideo_decode_block_opcode_0x8;
+ ipvideo_decode_block[0x9] = ipvideo_decode_block_opcode_0x9;
+ ipvideo_decode_block[0xA] = ipvideo_decode_block_opcode_0xA;
+ ipvideo_decode_block[0xB] = ipvideo_decode_block_opcode_0xB;
+ ipvideo_decode_block[0xC] = ipvideo_decode_block_opcode_0xC;
+ ipvideo_decode_block[0xD] = ipvideo_decode_block_opcode_0xD;
+ ipvideo_decode_block[0xE] = ipvideo_decode_block_opcode_0xE;
+ ipvideo_decode_block[0xF] = ipvideo_decode_block_opcode_0xF;
+
+ s->current_frame.data[0] = s->last_frame.data[0] =
+ s->second_last_frame.data[0] = NULL;
+
+ return 0;
+}
+
+static int ipvideo_decode_frame(AVCodecContext *avctx,
+ void *data, int *data_size,
+ uint8_t *buf, int buf_size)
+{
+ IpvideoContext *s = avctx->priv_data;
+ AVPaletteControl *palette_control = (AVPaletteControl *)avctx->extradata;
+
+ if (palette_control->palette_changed) {
+ /* load the new palette and reset the palette control */
+ ipvideo_new_palette(s, palette_control->palette);
+ palette_control->palette_changed = 0;
+ }
+
+ s->decoding_map = buf;
+ s->buf = buf + s->decoding_map_size;
+ s->size = buf_size - s->decoding_map_size;
+
+ s->current_frame.reference = 3;
+ if (avctx->get_buffer(avctx, &s->current_frame)) {
+ printf (" Interplay Video: get_buffer() failed\n");
+ return -1;
+ }
+
+ ipvideo_decode_opcodes(s);
+
+ *data_size = sizeof(AVFrame);
+ *(AVFrame*)data = s->current_frame;
+
+ /* shuffle frames */
+ if (s->second_last_frame.data[0])
+ avctx->release_buffer(avctx, &s->second_last_frame);
+ s->second_last_frame = s->last_frame;
+ s->last_frame = s->current_frame;
+ s->current_frame.data[0] = NULL; /* catch any access attempts */
+
+ /* report that the buffer was completely consumed */
+ return buf_size;
+}
+
+static int ipvideo_decode_end(AVCodecContext *avctx)
+{
+ IpvideoContext *s = avctx->priv_data;
+
+ /* release the last frame */
+ if (s->last_frame.data[0])
+ avctx->release_buffer(avctx, &s->last_frame);
+ if (s->second_last_frame.data[0])
+ avctx->release_buffer(avctx, &s->second_last_frame);
+
+ return 0;
+}
+
+AVCodec interplay_video_decoder = {
+ "interplayvideo",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_INTERPLAY_VIDEO,
+ sizeof(IpvideoContext),
+ ipvideo_decode_init,
+ NULL,
+ ipvideo_decode_end,
+ ipvideo_decode_frame,
+ CODEC_CAP_DR1,
+};
diff --git a/src/libffmpeg/libavcodec/libpostproc/postprocess.c b/src/libffmpeg/libavcodec/libpostproc/postprocess.c
index 470c889d8..0db5341e3 100644
--- a/src/libffmpeg/libavcodec/libpostproc/postprocess.c
+++ b/src/libffmpeg/libavcodec/libpostproc/postprocess.c
@@ -213,9 +213,77 @@ static inline int isVertDC_C(uint8_t src[], int stride, PPContext *c){
static inline int isHorizMinMaxOk(uint8_t src[], int stride, int QP)
{
- if(abs(src[0] - src[7]) > 2*QP) return 0;
+ int i;
+#if 1
+ for(i=0; i<2; i++){
+ if((unsigned)(src[0] - src[5] + 2*QP) > 4*QP) return 0;
+ src += stride;
+ if((unsigned)(src[2] - src[7] + 2*QP) > 4*QP) return 0;
+ src += stride;
+ if((unsigned)(src[4] - src[1] + 2*QP) > 4*QP) return 0;
+ src += stride;
+ if((unsigned)(src[6] - src[3] + 2*QP) > 4*QP) return 0;
+ src += stride;
+ }
+#else
+ for(i=0; i<8; i++){
+ if((unsigned)(src[0] - src[7] + 2*QP) > 4*QP) return 0;
+ src += stride;
+ }
+#endif
+ return 1;
+}
+static inline int isVertMinMaxOk_C(uint8_t src[], int stride, int QP)
+{
+#if 1
+#if 1
+ int x;
+ src+= stride*4;
+ for(x=0; x<BLOCK_SIZE; x+=4)
+ {
+ if((unsigned)(src[ x + 0*stride] - src[ x + 5*stride] + 2*QP) > 4*QP) return 0;
+ if((unsigned)(src[1+x + 2*stride] - src[1+x + 7*stride] + 2*QP) > 4*QP) return 0;
+ if((unsigned)(src[2+x + 4*stride] - src[2+x + 1*stride] + 2*QP) > 4*QP) return 0;
+ if((unsigned)(src[3+x + 6*stride] - src[3+x + 3*stride] + 2*QP) > 4*QP) return 0;
+ }
+#else
+ int x;
+ src+= stride*3;
+ for(x=0; x<BLOCK_SIZE; x++)
+ {
+ if((unsigned)(src[x + stride] - src[x + (stride<<3)] + 2*QP) > 4*QP) return 0;
+ }
+#endif
return 1;
+#else
+ int x;
+ src+= stride*4;
+ for(x=0; x<BLOCK_SIZE; x++)
+ {
+ int min=255;
+ int max=0;
+ int y;
+ for(y=0; y<8; y++){
+ int v= src[x + y*stride];
+ if(v>max) max=v;
+ if(v<min) min=v;
+ }
+ if(max-min > 2*QP) return 0;
+ }
+ return 1;
+#endif
+}
+
+static inline int vertClassify_C(uint8_t src[], int stride, PPContext *c){
+ if( isVertDC_C(src, stride, c) ){
+ if( isVertMinMaxOk_C(src, stride, c->QP) )
+ return 1;
+ else
+ return 0;
+ }else{
+ return 2;
+ }
}
static inline void doHorizDefFilter(uint8_t dst[], int stride, int QP)
@@ -481,18 +549,18 @@ char *pp_help=
"tn:64:128:256\n"
"Filters Options\n"
"short long name short long option Description\n"
-"* * a autoq cpu power dependant enabler\n"
-" c chrom chrominance filtring enabled\n"
-" y nochrom chrominance filtring disabled\n"
-"hb hdeblock (2 Threshold) horizontal deblocking filter\n"
+"* * a autoq CPU power dependent enabler\n"
+" c chrom chrominance filtering enabled\n"
+" y nochrom chrominance filtering disabled\n"
+"hb hdeblock (2 threshold) horizontal deblocking filter\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"
-"h1 x1hdeblock Experimental h deblock filter 1\n"
-"v1 x1vdeblock Experimental v deblock filter 1\n"
-"dr dering Deringing filter\n"
+" so you can't set different thresholds for h / v\n"
+"vb vdeblock (2 threshold) vertical deblocking filter\n"
+"h1 x1hdeblock experimental h deblock filter 1\n"
+"v1 x1vdeblock experimental v deblock filter 1\n"
+"dr dering deringing filter\n"
"al autolevels automatic brightness / contrast\n"
" f fullyrange stretch luminance to (0..255)\n"
"lb linblenddeint linear blend deinterlacer\n"
@@ -502,9 +570,9 @@ char *pp_help=
"fd ffmpegdeint ffmpeg deinterlacer\n"
"de default hb:a,vb:a,dr:a,al\n"
"fa fast h1:a,v1:a,dr:a,al\n"
-"tn tmpnoise (3 Thresholds) Temporal Noise Reducer\n"
+"tn tmpnoise (3 threshold) temporal noise reducer\n"
" 1. <= 2. <= 3. larger -> stronger filtering\n"
-"fq forceQuant <quantizer> Force quantizer\n"
+"fq forceQuant <quantizer> force quantizer\n"
;
pp_mode_t *pp_get_mode_by_name_and_quality(char *name, int quality)
diff --git a/src/libffmpeg/libavcodec/libpostproc/postprocess_template.c b/src/libffmpeg/libavcodec/libpostproc/postprocess_template.c
index 48027e417..582ad28f2 100644
--- a/src/libffmpeg/libavcodec/libpostproc/postprocess_template.c
+++ b/src/libffmpeg/libavcodec/libpostproc/postprocess_template.c
@@ -49,65 +49,85 @@
"paddb " #a ", " #b " \n\t"
#endif
-
//FIXME? |255-0| = 1 (shouldnt be a problem ...)
#ifdef HAVE_MMX
/**
* Check if the middle 8x8 Block in the given 8x16 block is flat
*/
-static inline int RENAME(isVertDC)(uint8_t src[], int stride, PPContext *c){
- int numEq= 0;
+static inline int RENAME(vertClassify)(uint8_t src[], int stride, PPContext *c){
+ int numEq= 0, dcOk;
src+= stride*4; // src points to begin of the 8x8 Block
asm volatile(
- "leal (%1, %2), %%eax \n\t"
+ "movq %0, %%mm7 \n\t"
+ "movq %1, %%mm6 \n\t"
+ : : "m" (c->mmxDcOffset[c->nonBQP]), "m" (c->mmxDcThreshold[c->nonBQP])
+ );
+
+asm volatile(
+ "leal (%2, %3), %%eax \n\t"
// 0 1 2 3 4 5 6 7 8 9
// %1 eax eax+%2 eax+2%2 %1+4%2 ecx ecx+%2 ecx+2%2 %1+8%2 ecx+4%2
- "movq %3, %%mm7 \n\t"
- "movq %4, %%mm6 \n\t"
- "movq (%1), %%mm0 \n\t"
+ "movq (%2), %%mm0 \n\t"
"movq (%%eax), %%mm1 \n\t"
+ "movq %%mm0, %%mm3 \n\t"
+ "movq %%mm0, %%mm4 \n\t"
+ PMAXUB(%%mm1, %%mm4)
+ PMINUB(%%mm1, %%mm3, %%mm5)
"psubb %%mm1, %%mm0 \n\t" // mm0 = differnece
"paddb %%mm7, %%mm0 \n\t"
"pcmpgtb %%mm6, %%mm0 \n\t"
- "movq (%%eax,%2), %%mm2 \n\t"
+ "movq (%%eax,%3), %%mm2 \n\t"
+ PMAXUB(%%mm2, %%mm4)
+ PMINUB(%%mm2, %%mm3, %%mm5)
"psubb %%mm2, %%mm1 \n\t"
"paddb %%mm7, %%mm1 \n\t"
"pcmpgtb %%mm6, %%mm1 \n\t"
"paddb %%mm1, %%mm0 \n\t"
- "movq (%%eax, %2, 2), %%mm1 \n\t"
+ "movq (%%eax, %3, 2), %%mm1 \n\t"
+ PMAXUB(%%mm1, %%mm4)
+ PMINUB(%%mm1, %%mm3, %%mm5)
"psubb %%mm1, %%mm2 \n\t"
"paddb %%mm7, %%mm2 \n\t"
"pcmpgtb %%mm6, %%mm2 \n\t"
"paddb %%mm2, %%mm0 \n\t"
- "leal (%%eax, %2, 4), %%eax \n\t"
+ "leal (%%eax, %3, 4), %%eax \n\t"
- "movq (%1, %2, 4), %%mm2 \n\t"
+ "movq (%2, %3, 4), %%mm2 \n\t"
+ PMAXUB(%%mm2, %%mm4)
+ PMINUB(%%mm2, %%mm3, %%mm5)
"psubb %%mm2, %%mm1 \n\t"
"paddb %%mm7, %%mm1 \n\t"
"pcmpgtb %%mm6, %%mm1 \n\t"
"paddb %%mm1, %%mm0 \n\t"
"movq (%%eax), %%mm1 \n\t"
+ PMAXUB(%%mm1, %%mm4)
+ PMINUB(%%mm1, %%mm3, %%mm5)
"psubb %%mm1, %%mm2 \n\t"
"paddb %%mm7, %%mm2 \n\t"
"pcmpgtb %%mm6, %%mm2 \n\t"
"paddb %%mm2, %%mm0 \n\t"
- "movq (%%eax, %2), %%mm2 \n\t"
+ "movq (%%eax, %3), %%mm2 \n\t"
+ PMAXUB(%%mm2, %%mm4)
+ PMINUB(%%mm2, %%mm3, %%mm5)
"psubb %%mm2, %%mm1 \n\t"
"paddb %%mm7, %%mm1 \n\t"
"pcmpgtb %%mm6, %%mm1 \n\t"
"paddb %%mm1, %%mm0 \n\t"
- "movq (%%eax, %2, 2), %%mm1 \n\t"
+ "movq (%%eax, %3, 2), %%mm1 \n\t"
+ PMAXUB(%%mm1, %%mm4)
+ PMINUB(%%mm1, %%mm3, %%mm5)
"psubb %%mm1, %%mm2 \n\t"
"paddb %%mm7, %%mm2 \n\t"
"pcmpgtb %%mm6, %%mm2 \n\t"
"paddb %%mm2, %%mm0 \n\t"
+ "psubusb %%mm3, %%mm4 \n\t"
" \n\t"
#ifdef HAVE_MMX2
@@ -124,69 +144,27 @@ asm volatile(
"psrlq $32, %%mm0 \n\t"
"paddb %%mm1, %%mm0 \n\t"
#endif
- "movd %%mm0, %0 \n\t"
- : "=r" (numEq)
- : "r" (src), "r" (stride), "m" (c->mmxDcOffset[c->nonBQP]), "m" (c->mmxDcThreshold[c->nonBQP])
- : "%eax"
- );
- numEq= (-numEq) &0xFF;
- return numEq > c->ppMode.flatnessThreshold;
-}
-#endif
-
-static inline int RENAME(isVertMinMaxOk)(uint8_t src[], int stride, PPContext *c)
-{
-#ifdef HAVE_MMX
- int isOk;
- src+= stride*3;
- asm volatile(
- "movq (%1, %2), %%mm0 \n\t"
- "movq (%1, %2, 8), %%mm1 \n\t"
- "movq %%mm0, %%mm2 \n\t"
- "psubusb %%mm1, %%mm0 \n\t"
- "psubusb %%mm2, %%mm1 \n\t"
- "por %%mm1, %%mm0 \n\t" // ABS Diff
-
- "movq %3, %%mm7 \n\t" // QP,..., QP
+ "movq %4, %%mm7 \n\t" // QP,..., QP
"paddusb %%mm7, %%mm7 \n\t" // 2QP ... 2QP
- "psubusb %%mm7, %%mm0 \n\t" // Diff <= 2QP -> 0
- "packssdw %%mm0, %%mm0 \n\t"
+ "psubusb %%mm7, %%mm4 \n\t" // Diff <= 2QP -> 0
+ "packssdw %%mm4, %%mm4 \n\t"
"movd %%mm0, %0 \n\t"
- : "=r" (isOk)
+ "movd %%mm4, %1 \n\t"
+
+ : "=r" (numEq), "=r" (dcOk)
: "r" (src), "r" (stride), "m" (c->pQPb)
+ : "%eax"
);
- return isOk==0;
-#else
-#if 1
- int x;
- const int QP= c->QP;
- src+= stride*3;
- for(x=0; x<BLOCK_SIZE; x++)
- {
- if((unsigned)(src[x + stride] - src[x + (stride<<3)] + 2*QP) > 4*QP) return 0;
- }
- return 1;
-#else
- int x;
- const int QP= c->QP;
- src+= stride*4;
- for(x=0; x<BLOCK_SIZE; x++)
- {
- int min=255;
- int max=0;
- int y;
- for(y=0; y<8; y++){
- int v= src[x + y*stride];
- if(v>max) max=v;
- if(v<min) min=v;
- }
- if(max-min > 2*QP) return 0;
- }
- return 1;
-#endif
-#endif
+ numEq= (-numEq) &0xFF;
+ if(numEq > c->ppMode.flatnessThreshold){
+ if(dcOk) return 0;
+ else return 1;
+ }else{
+ return 2;
+ }
}
+#endif
/**
* Do a vertical low pass filter on the 8x16 block (only write to the 8x8 block in the middle)
@@ -3119,12 +3097,11 @@ static void RENAME(postProcess)(uint8_t src[], int srcStride, uint8_t dst[], int
RENAME(vertX1Filter)(dstBlock, stride, &c);
else if(mode & V_DEBLOCK)
{
- if( RENAME(isVertDC)(dstBlock, stride, &c))
- {
- if(RENAME(isVertMinMaxOk)(dstBlock, stride, &c))
- RENAME(doVertLowPass)(dstBlock, stride, &c);
- }
- else
+ const int t= RENAME(vertClassify)(dstBlock, stride, &c);
+
+ if(t==1)
+ RENAME(doVertLowPass)(dstBlock, stride, &c);
+ else if(t==2)
RENAME(doVertDefFilter)(dstBlock, stride, &c);
}
}
@@ -3140,12 +3117,12 @@ static void RENAME(postProcess)(uint8_t src[], int srcStride, uint8_t dst[], int
RENAME(vertX1Filter)(tempBlock1, 16, &c);
else if(mode & H_DEBLOCK)
{
- if( RENAME(isVertDC)(tempBlock1, 16, &c))
- {
- if(RENAME(isVertMinMaxOk)(tempBlock1, 16, &c))
- RENAME(doVertLowPass)(tempBlock1, 16, &c);
- }
- else
+//START_TIMER
+ const int t= RENAME(vertClassify)(tempBlock1, 16, &c);
+//STOP_TIMER("dc & minmax")
+ if(t==1)
+ RENAME(doVertLowPass)(tempBlock1, 16, &c);
+ else if(t==2)
RENAME(doVertDefFilter)(tempBlock1, 16, &c);
}
diff --git a/src/libffmpeg/libavcodec/mdec.c b/src/libffmpeg/libavcodec/mdec.c
new file mode 100644
index 000000000..e093ee356
--- /dev/null
+++ b/src/libffmpeg/libavcodec/mdec.c
@@ -0,0 +1,276 @@
+/*
+ * PSX MDEC 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
+ *
+ * based upon code from Sebastian Jedruszkiewicz <elf@frogger.rules.pl>
+ */
+
+/**
+ * @file mdec.c
+ * PSX MDEC codec.
+ * This is very similar to intra only MPEG1.
+ */
+
+#include "avcodec.h"
+#include "dsputil.h"
+#include "mpegvideo.h"
+
+//#undef NDEBUG
+//#include <assert.h>
+
+typedef struct MDECContext{
+ AVCodecContext *avctx;
+ DSPContext dsp;
+ AVFrame picture;
+ PutBitContext pb;
+ GetBitContext gb;
+ ScanTable scantable;
+ int version;
+ int qscale;
+ int last_dc[3];
+ int mb_width;
+ int mb_height;
+ int mb_x, mb_y;
+ DCTELEM __align8 block[6][64];
+ uint16_t __align8 intra_matrix[64];
+ int __align8 q_intra_matrix[64];
+ uint8_t *bitstream_buffer;
+ int bitstream_buffer_size;
+ int block_last_index[6];
+} MDECContext;
+
+//very similar to mpeg1
+static inline int mdec_decode_block_intra(MDECContext *a, DCTELEM *block, int n)
+{
+ int level, diff, i, j, run;
+ int component;
+ RLTable *rl = &rl_mpeg1;
+ uint8_t * const scantable= a->scantable.permutated;
+ const uint16_t *quant_matrix= ff_mpeg1_default_intra_matrix;
+ const int qscale= a->qscale;
+
+ /* DC coef */
+ if(a->version==2){
+ block[0]= 2*get_sbits(&a->gb, 10) + 1024;
+ }else{
+ component = (n <= 3 ? 0 : n - 4 + 1);
+ diff = decode_dc(&a->gb, component);
+ if (diff >= 0xffff)
+ return -1;
+ a->last_dc[component]+= diff;
+ block[0] = a->last_dc[component]<<3;
+ }
+
+ i = 0;
+ {
+ OPEN_READER(re, &a->gb);
+ /* now quantify & encode AC coefs */
+ for(;;) {
+ UPDATE_CACHE(re, &a->gb);
+ GET_RL_VLC(level, run, re, &a->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2);
+
+ if(level == 127){
+ break;
+ } else if(level != 0) {
+ i += run;
+ j = scantable[i];
+ level= (level*qscale*quant_matrix[j])>>3;
+// level= (level-1)|1;
+ level = (level ^ SHOW_SBITS(re, &a->gb, 1)) - SHOW_SBITS(re, &a->gb, 1);
+ LAST_SKIP_BITS(re, &a->gb, 1);
+ } else {
+ /* escape */
+ run = SHOW_UBITS(re, &a->gb, 6)+1; LAST_SKIP_BITS(re, &a->gb, 6);
+ UPDATE_CACHE(re, &a->gb);
+ level = SHOW_SBITS(re, &a->gb, 10); SKIP_BITS(re, &a->gb, 10);
+ i += run;
+ j = scantable[i];
+ if(level<0){
+ level= -level;
+ level= (level*qscale*quant_matrix[j])>>3;
+ level= (level-1)|1;
+ level= -level;
+ }else{
+ level= (level*qscale*quant_matrix[j])>>3;
+ level= (level-1)|1;
+ }
+ }
+ if (i > 63){
+ fprintf(stderr, "ac-tex damaged at %d %d\n", a->mb_x, a->mb_y);
+ return -1;
+ }
+
+ block[j] = level;
+ }
+ CLOSE_READER(re, &a->gb);
+ }
+ a->block_last_index[n] = i;
+ return 0;
+}
+
+static inline int decode_mb(MDECContext *a, DCTELEM block[6][64]){
+ int i;
+ const int block_index[6]= {5,4,0,1,2,3};
+
+ a->dsp.clear_blocks(block[0]);
+
+ for(i=0; i<6; i++){
+ if( mdec_decode_block_intra(a, block[ block_index[i] ], block_index[i]) < 0)
+ return -1;
+ }
+ return 0;
+}
+
+static inline void idct_put(MDECContext *a, int mb_x, int mb_y){
+ DCTELEM (*block)[64]= a->block;
+ int linesize= a->picture.linesize[0];
+
+ uint8_t *dest_y = a->picture.data[0] + (mb_y * 16* linesize ) + mb_x * 16;
+ uint8_t *dest_cb = a->picture.data[1] + (mb_y * 8 * a->picture.linesize[1]) + mb_x * 8;
+ uint8_t *dest_cr = a->picture.data[2] + (mb_y * 8 * a->picture.linesize[2]) + mb_x * 8;
+
+ a->dsp.idct_put(dest_y , linesize, block[0]);
+ a->dsp.idct_put(dest_y + 8, linesize, block[1]);
+ a->dsp.idct_put(dest_y + 8*linesize , linesize, block[2]);
+ a->dsp.idct_put(dest_y + 8*linesize + 8, linesize, block[3]);
+
+ if(!(a->avctx->flags&CODEC_FLAG_GRAY)){
+ a->dsp.idct_put(dest_cb, a->picture.linesize[1], block[4]);
+ a->dsp.idct_put(dest_cr, a->picture.linesize[2], block[5]);
+ }
+}
+
+static int decode_frame(AVCodecContext *avctx,
+ void *data, int *data_size,
+ uint8_t *buf, int buf_size)
+{
+ MDECContext * const a = avctx->priv_data;
+ AVFrame *picture = data;
+ AVFrame * const p= (AVFrame*)&a->picture;
+ int i;
+
+ *data_size = 0;
+
+ /* special case for last picture */
+ if (buf_size == 0) {
+ return 0;
+ }
+
+ if(p->data[0])
+ avctx->release_buffer(avctx, p);
+
+ p->reference= 0;
+ if(avctx->get_buffer(avctx, p) < 0){
+ fprintf(stderr, "get_buffer() failed\n");
+ return -1;
+ }
+ p->pict_type= I_TYPE;
+ p->key_frame= 1;
+ a->last_dc[0]=
+ a->last_dc[1]=
+ a->last_dc[2]= 0;
+
+ a->bitstream_buffer= av_fast_realloc(a->bitstream_buffer, &a->bitstream_buffer_size, buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
+ for(i=0; i<buf_size; i+=2){
+ a->bitstream_buffer[i] = buf[i+1];
+ a->bitstream_buffer[i+1]= buf[i ];
+ }
+ init_get_bits(&a->gb, a->bitstream_buffer, buf_size*8);
+
+ /* skip over 4 preamble bytes in stream (typically 0xXX 0xXX 0x00 0x38) */
+ skip_bits(&a->gb, 32);
+
+ a->qscale= get_bits(&a->gb, 16);
+ a->version= get_bits(&a->gb, 16);
+
+// printf("qscale:%d (0x%X), version:%d (0x%X)\n", a->qscale, a->qscale, a->version, a->version);
+
+ for(a->mb_x=0; a->mb_x<a->mb_width; a->mb_x++){
+ for(a->mb_y=0; a->mb_y<a->mb_height; a->mb_y++){
+ if( decode_mb(a, a->block) <0)
+ return -1;
+
+ idct_put(a, a->mb_x, a->mb_y);
+ }
+ }
+
+// p->quality= (32 + a->inv_qscale/2)/a->inv_qscale;
+// memset(p->qscale_table, p->quality, p->qstride*a->mb_height);
+
+ *picture= *(AVFrame*)&a->picture;
+ *data_size = sizeof(AVPicture);
+
+ emms_c();
+
+ return (get_bits_count(&a->gb)+31)/32*4;
+}
+
+static void mdec_common_init(AVCodecContext *avctx){
+ MDECContext * const a = avctx->priv_data;
+
+ dsputil_init(&a->dsp, avctx);
+
+ a->mb_width = (avctx->width + 15) / 16;
+ a->mb_height = (avctx->height + 15) / 16;
+
+ avctx->coded_frame= (AVFrame*)&a->picture;
+ a->avctx= avctx;
+}
+
+static int decode_init(AVCodecContext *avctx){
+ MDECContext * const a = avctx->priv_data;
+ AVFrame *p= (AVFrame*)&a->picture;
+
+ mdec_common_init(avctx);
+ init_vlcs();
+ ff_init_scantable(a->dsp.idct_permutation, &a->scantable, ff_zigzag_direct);
+/*
+ for(i=0; i<64; i++){
+ int index= ff_zigzag_direct[i];
+ a->intra_matrix[i]= 64*ff_mpeg1_default_intra_matrix[index] / a->inv_qscale;
+ }
+*/
+ p->qstride= a->mb_width;
+ p->qscale_table= av_mallocz( p->qstride * a->mb_height);
+
+ return 0;
+}
+
+static int decode_end(AVCodecContext *avctx){
+ MDECContext * const a = avctx->priv_data;
+
+ av_freep(&a->bitstream_buffer);
+ av_freep(&a->picture.qscale_table);
+ a->bitstream_buffer_size=0;
+
+ avcodec_default_free_buffers(avctx);
+
+ return 0;
+}
+
+AVCodec mdec_decoder = {
+ "mdec",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_MDEC,
+ sizeof(MDECContext),
+ decode_init,
+ NULL,
+ decode_end,
+ decode_frame,
+ CODEC_CAP_DR1,
+};
+
diff --git a/src/libffmpeg/libavcodec/mjpeg.c b/src/libffmpeg/libavcodec/mjpeg.c
index 1b6b15c4a..48f528f88 100644
--- a/src/libffmpeg/libavcodec/mjpeg.c
+++ b/src/libffmpeg/libavcodec/mjpeg.c
@@ -243,6 +243,7 @@ static void build_huffman_codes(uint8_t *huff_size, uint16_t *huff_code,
}
}
+#ifdef CONFIG_ENCODERS
int mjpeg_init(MpegEncContext *s)
{
MJpegContext *m;
@@ -280,6 +281,7 @@ void mjpeg_close(MpegEncContext *s)
{
av_free(s->mjpeg_ctx);
}
+#endif //CONFIG_ENCODERS
#define PREDICT(ret, topleft, top, left, predictor)\
switch(predictor){\
@@ -289,9 +291,11 @@ void mjpeg_close(MpegEncContext *s)
case 4: ret= left + top - topleft; break;\
case 5: ret= left + ((top - topleft)>>1); break;\
case 6: ret= top + ((left - topleft)>>1); break;\
+ default:\
case 7: ret= (left + top)>>1; break;\
}
+#ifdef CONFIG_ENCODERS
static inline void put_marker(PutBitContext *p, int code)
{
put_bits(p, 8, 0xff);
@@ -377,28 +381,8 @@ static void jpeg_put_comments(MpegEncContext *s)
put_string(p, "JFIF"); /* this puts the trailing zero-byte too */
put_bits(p, 16, 0x0201); /* v 1.02 */
put_bits(p, 8, 0); /* units type: 0 - aspect ratio */
- switch(s->aspect_ratio_info)
- {
- case FF_ASPECT_4_3_625:
- case FF_ASPECT_4_3_525:
- put_bits(p, 16, 4);
- put_bits(p, 16, 3);
- break;
- case FF_ASPECT_16_9_625:
- case FF_ASPECT_16_9_525:
- put_bits(p, 16, 16);
- put_bits(p, 16, 9);
- break;
- case FF_ASPECT_EXTENDED:
- put_bits(p, 16, s->aspected_width);
- put_bits(p, 16, s->aspected_height);
- break;
- case FF_ASPECT_SQUARE:
- default:
- put_bits(p, 16, 1); /* aspect: 1:1 */
- put_bits(p, 16, 1);
- break;
- }
+ put_bits(p, 16, s->avctx->sample_aspect_ratio.num);
+ put_bits(p, 16, s->avctx->sample_aspect_ratio.den);
put_bits(p, 8, 0); /* thumbnail width */
put_bits(p, 8, 0); /* thumbnail height */
}
@@ -575,7 +559,7 @@ static inline void mjpeg_encode_dc(MpegEncContext *s, int val,
mant--;
}
- nbits= av_log2(val) + 1;
+ nbits= av_log2_16bit(val) + 1;
put_bits(&s->pb, huff_size[nbits], huff_code[nbits]);
@@ -659,7 +643,7 @@ static int encode_picture_lossless(AVCodecContext *avctx, unsigned char *buf, in
AVFrame * const p= (AVFrame*)&s->current_picture;
const int predictor= avctx->prediction_method+1;
- init_put_bits(&s->pb, buf, buf_size, NULL, NULL);
+ init_put_bits(&s->pb, buf, buf_size);
*p = *pict;
p->pict_type= FF_I_TYPE;
@@ -680,7 +664,7 @@ static int encode_picture_lossless(AVCodecContext *avctx, unsigned char *buf, in
}
for(y = 0; y < height; y++) {
- const int modified_predictor= y ? 1 : predictor;
+ const int modified_predictor= y ? predictor : 1;
uint8_t *ptr = p->data[0] + (linesize * y);
for(i=0; i<3; i++){
@@ -789,6 +773,7 @@ static int encode_picture_lossless(AVCodecContext *avctx, unsigned char *buf, in
// return (get_bit_count(&f->pb)+7)/8;
}
+#endif //CONFIG_ENCODERS
/******************************************/
/* decoding */
@@ -806,6 +791,7 @@ typedef struct MJpegDecodeContext {
int16_t quant_matrixes[4][64];
VLC vlcs[2][4];
+ int qscale[4]; ///< quantizer scale calculated from quant_matrixes
int org_width, org_height; /* size given at codec init */
int first_picture; /* true if decoding first picture */
@@ -818,15 +804,23 @@ typedef struct MJpegDecodeContext {
int bits; /* bits per component */
int width, height;
+ int mb_width, mb_height;
int nb_components;
int component_id[MAX_COMPONENTS];
int h_count[MAX_COMPONENTS]; /* horizontal and vertical count for each component */
int v_count[MAX_COMPONENTS];
+ int comp_index[MAX_COMPONENTS];
+ int dc_index[MAX_COMPONENTS];
+ int ac_index[MAX_COMPONENTS];
+ int nb_blocks[MAX_COMPONENTS];
+ int h_scount[MAX_COMPONENTS];
+ int v_scount[MAX_COMPONENTS];
int h_max, v_max; /* maximum h and v counts */
int quant_index[4]; /* quant table index for each component */
int last_dc[MAX_COMPONENTS]; /* last DEQUANTIZED dc (XXX: am I right to do that ?) */
- uint8_t *current_picture[MAX_COMPONENTS]; /* picture structure */
- int linesize[MAX_COMPONENTS];
+ AVFrame picture; /* picture structure */
+ int linesize[MAX_COMPONENTS]; ///< linesize << interlaced
+ uint8_t *qscale_table;
DCTELEM block[64] __align8;
ScanTable scantable;
void (*idct_put)(uint8_t *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/);
@@ -840,7 +834,7 @@ typedef struct MJpegDecodeContext {
static int mjpeg_decode_dht(MJpegDecodeContext *s);
-static void build_vlc(VLC *vlc, const uint8_t *bits_table, const uint8_t *val_table,
+static int build_vlc(VLC *vlc, const uint8_t *bits_table, const uint8_t *val_table,
int nb_codes)
{
uint8_t huff_size[256];
@@ -849,7 +843,7 @@ static void build_vlc(VLC *vlc, const uint8_t *bits_table, const uint8_t *val_ta
memset(huff_size, 0, sizeof(huff_size));
build_huffman_codes(huff_size, huff_code, bits_table, val_table);
- init_vlc(vlc, 9, nb_codes, huff_size, 1, 1, huff_code, 2, 2);
+ return init_vlc(vlc, 9, nb_codes, huff_size, 1, 1, huff_code, 2, 2);
}
static int mjpeg_decode_init(AVCodecContext *avctx)
@@ -922,6 +916,12 @@ static int mjpeg_decode_dqt(MJpegDecodeContext *s)
j = s->scantable.permutated[i];
s->quant_matrixes[index][j] = get_bits(&s->gb, 8);
}
+
+ //XXX FIXME finetune, and perhaps add dc too
+ s->qscale[index]= FFMAX(
+ s->quant_matrixes[index][s->scantable.permutated[1]],
+ s->quant_matrixes[index][s->scantable.permutated[8]]) >> 1;
+ dprintf("qscale[%d]: %d\n", index, s->qscale[index]);
len -= 65;
}
@@ -968,7 +968,9 @@ static int mjpeg_decode_dht(MJpegDecodeContext *s)
free_vlc(&s->vlcs[class][index]);
dprintf("class=%d index=%d nb_codes=%d\n",
class, index, code_max + 1);
- build_vlc(&s->vlcs[class][index], bits_table, val_table, code_max + 1);
+ if(build_vlc(&s->vlcs[class][index], bits_table, val_table, code_max + 1) < 0){
+ return -1;
+ }
}
return 0;
}
@@ -1021,8 +1023,8 @@ static int mjpeg_decode_sof(MJpegDecodeContext *s)
/* if different size, realloc/alloc picture */
/* XXX: also check h_count and v_count */
if (width != s->width || height != s->height) {
- for(i=0;i<MAX_COMPONENTS;i++)
- av_freep(&s->current_picture[i]);
+ av_freep(&s->qscale_table);
+
s->width = width;
s->height = height;
/* test interlaced mode */
@@ -1034,36 +1036,48 @@ static int mjpeg_decode_sof(MJpegDecodeContext *s)
s->bottom_field = 0;
}
- if(s->rgb){
- int w, h;
- w = s->width;
- h = s->height;
- if (s->interlaced)
- w *= 2;
- s->linesize[0] = 4*w;
- s->current_picture[0] = av_mallocz(4*w * h);
- s->current_picture[1] = s->current_picture[2] = NULL;
- }else{
- for(i=0;i<nb_components;i++) {
- int w, h;
- w = (s->width + 8 * s->h_max - 1) / (8 * s->h_max);
- h = (s->height + 8 * s->v_max - 1) / (8 * s->v_max);
- w = w * 8 * s->h_count[i];
- h = h * 8 * s->v_count[i];
- if (s->interlaced)
- w *= 2;
- s->linesize[i] = w;
- s->current_picture[i] = av_mallocz(w * h);
- if (!s->current_picture[i])
- {
- dprintf("error: no picture buffers allocated\n");
- return -1;
- }
- }
- }
+ s->qscale_table= av_mallocz((s->width+15)/16);
+
s->first_picture = 0;
}
+
+ if(s->interlaced && s->bottom_field)
+ return 0;
+
+ /* XXX: not complete test ! */
+ switch((s->h_count[0] << 4) | s->v_count[0]) {
+ case 0x11:
+ if(s->rgb){
+ s->avctx->pix_fmt = PIX_FMT_RGBA32;
+ }else
+ s->avctx->pix_fmt = PIX_FMT_YUV444P;
+ break;
+ case 0x21:
+ s->avctx->pix_fmt = PIX_FMT_YUV422P;
+ break;
+ default:
+ case 0x22:
+ s->avctx->pix_fmt = PIX_FMT_YUV420P;
+ break;
+ }
+ if(s->picture.data[0])
+ s->avctx->release_buffer(s->avctx, &s->picture);
+
+ s->picture.reference= 0;
+ if(s->avctx->get_buffer(s->avctx, &s->picture) < 0){
+ fprintf(stderr, "get_buffer() failed\n");
+ return -1;
+ }
+ s->picture.pict_type= I_TYPE;
+ s->picture.key_frame= 1;
+
+ for(i=0; i<3; i++){
+ s->linesize[i]= s->picture.linesize[i] << s->interlaced;
+ }
+
+// printf("%d %d %d %d %d %d\n", s->width, s->height, s->linesize[0], s->linesize[1], s->interlaced, s->avctx->height);
+
if (len != (8+(3*nb_components)))
{
dprintf("decode_sof0: error, len(%d) mismatch\n", len);
@@ -1139,16 +1153,211 @@ static int decode_block(MJpegDecodeContext *s, DCTELEM *block,
return 0;
}
+static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int predictor, int point_transform){
+ int i, mb_x, mb_y;
+ uint16_t buffer[2048][4];
+ int left[3], top[3], topleft[3];
+ const int linesize= s->linesize[0];
+ const int mask= (1<<s->bits)-1;
+
+ for(i=0; i<3; i++){
+ buffer[0][i]= 1 << (s->bits + point_transform - 1);
+ }
+ for(mb_y = 0; mb_y < s->mb_height; mb_y++) {
+ const int modified_predictor= mb_y ? predictor : 1;
+ uint8_t *ptr = s->picture.data[0] + (linesize * mb_y);
+
+ if (s->interlaced && s->bottom_field)
+ ptr += linesize >> 1;
+
+ for(i=0; i<3; i++){
+ top[i]= left[i]= topleft[i]= buffer[0][i];
+ }
+ for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
+ if (s->restart_interval && !s->restart_count)
+ s->restart_count = s->restart_interval;
+
+ for(i=0;i<3;i++) {
+ int pred;
+
+ topleft[i]= top[i];
+ top[i]= buffer[mb_x][i];
+
+ PREDICT(pred, topleft[i], top[i], left[i], modified_predictor);
+
+ left[i]=
+ buffer[mb_x][i]= mask & (pred + (mjpeg_decode_dc(s, s->dc_index[i]) << point_transform));
+ }
+
+ if (s->restart_interval && !--s->restart_count) {
+ align_get_bits(&s->gb);
+ skip_bits(&s->gb, 16); /* skip RSTn */
+ }
+ }
+
+ if(s->rct){
+ for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
+ ptr[4*mb_x+1] = buffer[mb_x][0] - ((buffer[mb_x][1] + buffer[mb_x][2] - 0x200)>>2);
+ ptr[4*mb_x+0] = buffer[mb_x][1] + ptr[4*mb_x+1];
+ ptr[4*mb_x+2] = buffer[mb_x][2] + ptr[4*mb_x+1];
+ }
+ }else if(s->pegasus_rct){
+ for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
+ ptr[4*mb_x+1] = buffer[mb_x][0] - ((buffer[mb_x][1] + buffer[mb_x][2])>>2);
+ ptr[4*mb_x+0] = buffer[mb_x][1] + ptr[4*mb_x+1];
+ ptr[4*mb_x+2] = buffer[mb_x][2] + ptr[4*mb_x+1];
+ }
+ }else{
+ for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
+ ptr[4*mb_x+0] = buffer[mb_x][0];
+ ptr[4*mb_x+1] = buffer[mb_x][1];
+ ptr[4*mb_x+2] = buffer[mb_x][2];
+ }
+ }
+ }
+ return 0;
+}
+
+static int ljpeg_decode_yuv_scan(MJpegDecodeContext *s, int predictor, int point_transform){
+ int i, mb_x, mb_y;
+ const int nb_components=3;
+
+ for(mb_y = 0; mb_y < s->mb_height; mb_y++) {
+ for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
+ if (s->restart_interval && !s->restart_count)
+ s->restart_count = s->restart_interval;
+
+ if(mb_x==0 || mb_y==0 || s->interlaced){
+ for(i=0;i<nb_components;i++) {
+ uint8_t *ptr;
+ int n, h, v, x, y, c, j, linesize;
+ n = s->nb_blocks[i];
+ c = s->comp_index[i];
+ h = s->h_scount[i];
+ v = s->v_scount[i];
+ x = 0;
+ y = 0;
+ linesize= s->linesize[c];
+
+ for(j=0; j<n; j++) {
+ int pred;
+
+ ptr = s->picture.data[c] + (linesize * (v * mb_y + y)) + (h * mb_x + x); //FIXME optimize this crap
+ if(y==0 && mb_y==0){
+ if(x==0 && mb_x==0){
+ pred= 128 << point_transform;
+ }else{
+ pred= ptr[-1];
+ }
+ }else{
+ if(x==0 && mb_x==0){
+ pred= ptr[-linesize];
+ }else{
+ PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor);
+ }
+ }
+
+ if (s->interlaced && s->bottom_field)
+ ptr += linesize >> 1;
+ *ptr= pred + (mjpeg_decode_dc(s, s->dc_index[i]) << point_transform);
+
+ if (++x == h) {
+ x = 0;
+ y++;
+ }
+ }
+ }
+ }else{
+ for(i=0;i<nb_components;i++) {
+ uint8_t *ptr;
+ int n, h, v, x, y, c, j, linesize;
+ n = s->nb_blocks[i];
+ c = s->comp_index[i];
+ h = s->h_scount[i];
+ v = s->v_scount[i];
+ x = 0;
+ y = 0;
+ linesize= s->linesize[c];
+
+ for(j=0; j<n; j++) {
+ int pred;
+
+ ptr = s->picture.data[c] + (linesize * (v * mb_y + y)) + (h * mb_x + x); //FIXME optimize this crap
+ PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor);
+ *ptr= pred + (mjpeg_decode_dc(s, s->dc_index[i]) << point_transform);
+ if (++x == h) {
+ x = 0;
+ y++;
+ }
+ }
+ }
+ }
+ if (s->restart_interval && !--s->restart_count) {
+ align_get_bits(&s->gb);
+ skip_bits(&s->gb, 16); /* skip RSTn */
+ }
+ }
+ }
+ return 0;
+}
+
+static int mjpeg_decode_scan(MJpegDecodeContext *s){
+ int i, mb_x, mb_y;
+ const int nb_components=3;
+
+ for(mb_y = 0; mb_y < s->mb_height; mb_y++) {
+ for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
+ if (s->restart_interval && !s->restart_count)
+ s->restart_count = s->restart_interval;
+
+ for(i=0;i<nb_components;i++) {
+ uint8_t *ptr;
+ int n, h, v, x, y, c, j;
+ n = s->nb_blocks[i];
+ c = s->comp_index[i];
+ h = s->h_scount[i];
+ v = s->v_scount[i];
+ x = 0;
+ y = 0;
+ for(j=0;j<n;j++) {
+ memset(s->block, 0, sizeof(s->block));
+ if (decode_block(s, s->block, i,
+ s->dc_index[i], s->ac_index[i],
+ s->quant_index[c]) < 0) {
+ dprintf("error y=%d x=%d\n", mb_y, mb_x);
+ return -1;
+ }
+// dprintf("mb: %d %d processed\n", mb_y, mb_x);
+ ptr = s->picture.data[c] +
+ (s->linesize[c] * (v * mb_y + y) * 8) +
+ (h * mb_x + x) * 8;
+ if (s->interlaced && s->bottom_field)
+ ptr += s->linesize[c] >> 1;
+//printf("%d %d %d %d %d %d %d %d \n", mb_x, mb_y, x, y, c, s->bottom_field, (v * mb_y + y) * 8, (h * mb_x + x) * 8);
+ s->idct_put(ptr, s->linesize[c], s->block);
+ if (++x == h) {
+ x = 0;
+ y++;
+ }
+ }
+ }
+ /* (< 1350) buggy workaround for Spectralfan.mov, should be fixed */
+ if (s->restart_interval && (s->restart_interval < 1350) &&
+ !--s->restart_count) {
+ align_get_bits(&s->gb);
+ skip_bits(&s->gb, 16); /* skip RSTn */
+ for (i=0; i<nb_components; i++) /* reset dc */
+ s->last_dc[i] = 1024;
+ }
+ }
+ }
+ return 0;
+}
+
static int mjpeg_decode_sos(MJpegDecodeContext *s)
{
- int len, nb_components, i, j, n, h, v, ret, point_transform, predictor;
- int mb_width, mb_height, mb_x, mb_y, vmax, hmax, index, id;
- int comp_index[4];
- int dc_index[4];
- int ac_index[4];
- int nb_blocks[4];
- int h_count[4];
- int v_count[4];
+ int len, nb_components, i, h, v, predictor, point_transform;
+ int vmax, hmax, index, id;
const int block_size= s->lossless ? 1 : 8;
/* XXX: verify len field validity */
@@ -1180,18 +1389,19 @@ static int mjpeg_decode_sos(MJpegDecodeContext *s)
return -1;
}
- comp_index[i] = index;
+ s->comp_index[i] = index;
- nb_blocks[i] = s->h_count[index] * s->v_count[index];
- h_count[i] = s->h_count[index];
- v_count[i] = s->v_count[index];
+ s->nb_blocks[i] = s->h_count[index] * s->v_count[index];
+ s->h_scount[i] = s->h_count[index];
+ s->v_scount[i] = s->v_count[index];
- dc_index[i] = get_bits(&s->gb, 4);
- ac_index[i] = get_bits(&s->gb, 4);
+ s->dc_index[i] = get_bits(&s->gb, 4);
+ s->ac_index[i] = get_bits(&s->gb, 4);
- if (dc_index[i] < 0 || ac_index[i] < 0 ||
- dc_index[i] >= 4 || ac_index[i] >= 4)
+ if (s->dc_index[i] < 0 || s->ac_index[i] < 0 ||
+ s->dc_index[i] >= 4 || s->ac_index[i] >= 4)
goto out_of_range;
+#if 0 //buggy
switch(s->start_code)
{
case SOF0:
@@ -1208,6 +1418,7 @@ static int mjpeg_decode_sos(MJpegDecodeContext *s)
goto out_of_range;
break;
}
+#endif
}
predictor= get_bits(&s->gb, 8); /* lossless predictor or start of spectral (Ss) */
@@ -1220,213 +1431,35 @@ static int mjpeg_decode_sos(MJpegDecodeContext *s)
if (nb_components > 1) {
/* interleaved stream */
- mb_width = (s->width + s->h_max * block_size - 1) / (s->h_max * block_size);
- mb_height = (s->height + s->v_max * block_size - 1) / (s->v_max * block_size);
+ s->mb_width = (s->width + s->h_max * block_size - 1) / (s->h_max * block_size);
+ s->mb_height = (s->height + s->v_max * block_size - 1) / (s->v_max * block_size);
} else {
- h = s->h_max / s->h_count[comp_index[0]];
- v = s->v_max / s->v_count[comp_index[0]];
- mb_width = (s->width + h * block_size - 1) / (h * block_size);
- mb_height = (s->height + v * block_size - 1) / (v * block_size);
- nb_blocks[0] = 1;
- h_count[0] = 1;
- v_count[0] = 1;
+ h = s->h_max / s->h_scount[s->comp_index[0]];
+ v = s->v_max / s->v_scount[s->comp_index[0]];
+ s->mb_width = (s->width + h * block_size - 1) / (h * block_size);
+ s->mb_height = (s->height + v * block_size - 1) / (v * block_size);
+ s->nb_blocks[0] = 1;
+ s->h_scount[0] = 1;
+ s->v_scount[0] = 1;
}
if(s->avctx->debug & FF_DEBUG_PICT_INFO)
printf("%s %s p:%d >>:%d\n", s->lossless ? "lossless" : "sequencial DCT", s->rgb ? "RGB" : "", predictor, point_transform);
if(s->lossless){
- if(s->rgb){
- uint16_t buffer[2048][4];
- int left[3], top[3], topleft[3];
- const int linesize= s->linesize[0];
- const int mask= (1<<s->bits)-1;
-
- for(i=0; i<3; i++){
- buffer[0][i]= 1 << (s->bits + point_transform - 1);
- }
- for(mb_y = 0; mb_y < mb_height; mb_y++) {
- const int modified_predictor= mb_y ? 1 : predictor;
- uint8_t *ptr = s->current_picture[0] + (linesize * mb_y);
-
- if (s->interlaced && s->bottom_field)
- ptr += linesize >> 1;
-
- for(i=0; i<3; i++){
- top[i]= left[i]= topleft[i]= buffer[0][i];
- }
- for(mb_x = 0; mb_x < mb_width; mb_x++) {
- if (s->restart_interval && !s->restart_count)
- s->restart_count = s->restart_interval;
-
- for(i=0;i<3;i++) {
- int pred;
-
- topleft[i]= top[i];
- top[i]= buffer[mb_x][i];
-
- PREDICT(pred, topleft[i], top[i], left[i], modified_predictor);
-
- left[i]=
- buffer[mb_x][i]= mask & (pred + (mjpeg_decode_dc(s, dc_index[i]) << point_transform));
- }
-
- if (s->restart_interval && !--s->restart_count) {
- align_get_bits(&s->gb);
- skip_bits(&s->gb, 16); /* skip RSTn */
- }
- }
-
- if(s->rct){
- for(mb_x = 0; mb_x < mb_width; mb_x++) {
- ptr[4*mb_x+1] = buffer[mb_x][0] - ((buffer[mb_x][1] + buffer[mb_x][2] - 0x200)>>2);
- ptr[4*mb_x+0] = buffer[mb_x][1] + ptr[4*mb_x+1];
- ptr[4*mb_x+2] = buffer[mb_x][2] + ptr[4*mb_x+1];
- }
- }else if(s->pegasus_rct){
- for(mb_x = 0; mb_x < mb_width; mb_x++) {
- ptr[4*mb_x+1] = buffer[mb_x][0] - ((buffer[mb_x][1] + buffer[mb_x][2])>>2);
- ptr[4*mb_x+0] = buffer[mb_x][1] + ptr[4*mb_x+1];
- ptr[4*mb_x+2] = buffer[mb_x][2] + ptr[4*mb_x+1];
- }
- }else{
- for(mb_x = 0; mb_x < mb_width; mb_x++) {
- ptr[4*mb_x+0] = buffer[mb_x][0];
- ptr[4*mb_x+1] = buffer[mb_x][1];
- ptr[4*mb_x+2] = buffer[mb_x][2];
- }
- }
- }
- }else{
- for(mb_y = 0; mb_y < mb_height; mb_y++) {
- for(mb_x = 0; mb_x < mb_width; mb_x++) {
- if (s->restart_interval && !s->restart_count)
- s->restart_count = s->restart_interval;
-
- if(mb_x==0 || mb_y==0 || s->interlaced){
- for(i=0;i<nb_components;i++) {
- uint8_t *ptr;
- int x, y, c, linesize;
- n = nb_blocks[i];
- c = comp_index[i];
- h = h_count[i];
- v = v_count[i];
- x = 0;
- y = 0;
- linesize= s->linesize[c];
-
- for(j=0; j<n; j++) {
- int pred;
-
- ptr = s->current_picture[c] + (linesize * (v * mb_y + y)) + (h * mb_x + x); //FIXME optimize this crap
- if(y==0 && mb_y==0){
- if(x==0 && mb_x==0){
- pred= 128 << point_transform;
- }else{
- pred= ptr[-1];
- }
- }else{
- if(x==0 && mb_x==0){
- pred= ptr[-linesize];
- }else{
- PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor);
- }
- }
-
- if (s->interlaced && s->bottom_field)
- ptr += linesize >> 1;
- *ptr= pred + (mjpeg_decode_dc(s, dc_index[i]) << point_transform);
-
- if (++x == h) {
- x = 0;
- y++;
- }
- }
- }
- }else{
- for(i=0;i<nb_components;i++) {
- uint8_t *ptr;
- int x, y, c, linesize;
- n = nb_blocks[i];
- c = comp_index[i];
- h = h_count[i];
- v = v_count[i];
- x = 0;
- y = 0;
- linesize= s->linesize[c];
-
- for(j=0; j<n; j++) {
- int pred;
-
- ptr = s->current_picture[c] + (linesize * (v * mb_y + y)) + (h * mb_x + x); //FIXME optimize this crap
- PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor);
- *ptr= pred + (mjpeg_decode_dc(s, dc_index[i]) << point_transform);
- if (++x == h) {
- x = 0;
- y++;
- }
- }
- }
- }
- if (s->restart_interval && !--s->restart_count) {
- align_get_bits(&s->gb);
- skip_bits(&s->gb, 16); /* skip RSTn */
- }
- }
+ if(s->rgb){
+ if(ljpeg_decode_rgb_scan(s, predictor, point_transform) < 0)
+ return -1;
+ }else{
+ if(ljpeg_decode_yuv_scan(s, predictor, point_transform) < 0)
+ return -1;
}
- }
}else{
- for(mb_y = 0; mb_y < mb_height; mb_y++) {
- for(mb_x = 0; mb_x < mb_width; mb_x++) {
- if (s->restart_interval && !s->restart_count)
- s->restart_count = s->restart_interval;
-
- for(i=0;i<nb_components;i++) {
- uint8_t *ptr;
- int x, y, c;
- n = nb_blocks[i];
- c = comp_index[i];
- h = h_count[i];
- v = v_count[i];
- x = 0;
- y = 0;
- for(j=0;j<n;j++) {
- memset(s->block, 0, sizeof(s->block));
- if (decode_block(s, s->block, i,
- dc_index[i], ac_index[i],
- s->quant_index[c]) < 0) {
- dprintf("error y=%d x=%d\n", mb_y, mb_x);
- ret = -1;
- goto the_end;
- }
-// dprintf("mb: %d %d processed\n", mb_y, mb_x);
- ptr = s->current_picture[c] +
- (s->linesize[c] * (v * mb_y + y) * 8) +
- (h * mb_x + x) * 8;
- if (s->interlaced && s->bottom_field)
- ptr += s->linesize[c] >> 1;
- s->idct_put(ptr, s->linesize[c], s->block);
- if (++x == h) {
- x = 0;
- y++;
- }
- }
- }
- /* (< 1350) buggy workaround for Spectralfan.mov, should be fixed */
- if (s->restart_interval && (s->restart_interval < 1350) &&
- !--s->restart_count) {
- align_get_bits(&s->gb);
- skip_bits(&s->gb, 16); /* skip RSTn */
- for (j=0; j<nb_components; j++) /* reset dc */
- s->last_dc[j] = 1024;
- }
- }
+ if(mjpeg_decode_scan(s) < 0)
+ return -1;
}
- }
- ret = 0;
- the_end:
emms_c();
- return ret;
+ return 0;
out_of_range:
dprintf("decode_sos: ac/dc index out of range\n");
return -1;
@@ -1494,29 +1527,10 @@ static int mjpeg_decode_app(MJpegDecodeContext *s)
skip_bits(&s->gb, 8); /* the trailing zero-byte */
printf("mjpeg: JFIF header found (version: %x.%x)\n",
get_bits(&s->gb, 8), get_bits(&s->gb, 8));
- if (get_bits(&s->gb, 8) == 0)
- {
- int x_density, y_density;
- x_density = get_bits(&s->gb, 16);
- y_density = get_bits(&s->gb, 16);
+ skip_bits(&s->gb, 8);
- dprintf("x/y density: %d (%f), %d (%f)\n", x_density,
- (float)x_density, y_density, (float)y_density);
-#if 0
- //MN: needs to be checked
- if(x_density)
-// s->avctx->aspect_ratio= s->width*y_density/((float)s->height*x_density);
- s->avctx->aspect_ratio = (float)x_density/y_density;
- /* it's better, but every JFIF I have seen stores 1:1 */
- else
- s->avctx->aspect_ratio= 0.0;
-#endif
- }
- else
- {
- skip_bits(&s->gb, 16);
- skip_bits(&s->gb, 16);
- }
+ s->avctx->sample_aspect_ratio.num= get_bits(&s->gb, 16);
+ s->avctx->sample_aspect_ratio.den= get_bits(&s->gb, 16);
t_w = get_bits(&s->gb, 8);
t_h = get_bits(&s->gb, 8);
@@ -1599,7 +1613,7 @@ out:
static int mjpeg_decode_com(MJpegDecodeContext *s)
{
/* XXX: verify len field validity */
- unsigned int len = get_bits(&s->gb, 16);
+ int len = get_bits(&s->gb, 16);
if (len >= 2 && len < 32768) {
/* XXX: any better upper bound */
uint8_t *cbuf = av_malloc(len - 1);
@@ -1667,7 +1681,7 @@ static int find_marker(uint8_t **pbuf_ptr, uint8_t *buf_end)
while (buf_ptr < buf_end) {
v = *buf_ptr++;
v2 = *buf_ptr;
- if ((buf_ptr < buf_end) && (v == 0xff) && (v2 >= 0xc0) && (v2 <= 0xfe)) {
+ if ((v == 0xff) && (v2 >= 0xc0) && (v2 <= 0xfe)) {
val = *buf_ptr++;
goto found;
}
@@ -1690,8 +1704,8 @@ static int mjpeg_decode_frame(AVCodecContext *avctx,
{
MJpegDecodeContext *s = avctx->priv_data;
uint8_t *buf_end, *buf_ptr;
- int i, start_code;
- AVPicture *picture = data;
+ int start_code;
+ AVFrame *picture = data;
*data_size = 0;
@@ -1776,7 +1790,10 @@ static int mjpeg_decode_frame(AVCodecContext *avctx,
mjpeg_decode_dqt(s);
break;
case DHT:
- mjpeg_decode_dht(s);
+ if(mjpeg_decode_dht(s) < 0){
+ fprintf(stderr, "huffman table decode error\n");
+ return -1;
+ }
break;
case SOF0:
s->lossless=0;
@@ -1789,6 +1806,8 @@ static int mjpeg_decode_frame(AVCodecContext *avctx,
return -1;
break;
case EOI:
+ if ((s->buggy_avid && !s->interlaced) || s->restart_interval)
+ break;
eoi_parser:
{
if (s->interlaced) {
@@ -1797,35 +1816,23 @@ eoi_parser:
if (s->bottom_field)
goto not_the_end;
}
- for(i=0;i<3;i++) {
- picture->data[i] = s->current_picture[i];
- picture->linesize[i] = (s->interlaced) ?
- s->linesize[i] >> 1 : s->linesize[i];
- }
- *data_size = sizeof(AVPicture);
+ *picture = s->picture;
+ *data_size = sizeof(AVFrame);
avctx->height = s->height;
if (s->interlaced)
avctx->height *= 2;
avctx->width = s->width;
- /* XXX: not complete test ! */
- switch((s->h_count[0] << 4) | s->v_count[0]) {
- case 0x11:
- if(s->rgb){
- avctx->pix_fmt = PIX_FMT_RGBA32;
- }else
- avctx->pix_fmt = PIX_FMT_YUV444P;
- break;
- case 0x21:
- avctx->pix_fmt = PIX_FMT_YUV422P;
- break;
- default:
- case 0x22:
- avctx->pix_fmt = PIX_FMT_YUV420P;
- break;
+
+ if(!s->lossless){
+ picture->quality= FFMAX(FFMAX(s->qscale[0], s->qscale[1]), s->qscale[2]);
+ picture->qstride= 0;
+ picture->qscale_table= s->qscale_table;
+ memset(picture->qscale_table, picture->quality, (s->width+15)/16);
+ if(avctx->debug & FF_DEBUG_QP)
+ printf("QP: %d\n", picture->quality);
+ picture->quality*= FF_QP2LAMBDA;
}
- /* dummy quality */
- /* XXX: infer it with matrix */
-// avctx->quality = 3;
+
goto the_end;
}
break;
@@ -1878,8 +1885,7 @@ static int mjpegb_decode_frame(AVCodecContext *avctx,
{
MJpegDecodeContext *s = avctx->priv_data;
uint8_t *buf_end, *buf_ptr;
- int i;
- AVPicture *picture = data;
+ AVFrame *picture = data;
GetBitContext hgb; /* for the header */
uint32_t dqt_offs, dht_offs, sof_offs, sos_offs, second_field_offs;
uint32_t field_size;
@@ -1966,36 +1972,189 @@ read_header:
}
}
- for(i=0;i<3;i++) {
- picture->data[i] = s->current_picture[i];
- picture->linesize[i] = (s->interlaced) ?
- s->linesize[i] >> 1 : s->linesize[i];
- }
- *data_size = sizeof(AVPicture);
+ //XXX FIXME factorize, this looks very similar to the EOI code
+
+ *picture= s->picture;
+ *data_size = sizeof(AVFrame);
avctx->height = s->height;
if (s->interlaced)
avctx->height *= 2;
avctx->width = s->width;
- /* XXX: not complete test ! */
- switch((s->h_count[0] << 4) | s->v_count[0]) {
- case 0x11:
- avctx->pix_fmt = PIX_FMT_YUV444P;
- break;
- case 0x21:
- avctx->pix_fmt = PIX_FMT_YUV422P;
- break;
- default:
- case 0x22:
- avctx->pix_fmt = PIX_FMT_YUV420P;
- break;
+
+ if(!s->lossless){
+ picture->quality= FFMAX(FFMAX(s->qscale[0], s->qscale[1]), s->qscale[2]);
+ picture->qstride= 0;
+ picture->qscale_table= s->qscale_table;
+ memset(picture->qscale_table, picture->quality, (s->width+15)/16);
+ if(avctx->debug & FF_DEBUG_QP)
+ printf("QP: %d\n", picture->quality);
+ picture->quality*= FF_QP2LAMBDA;
}
- /* dummy quality */
- /* XXX: infer it with matrix */
-// avctx->quality = 3;
return buf_ptr - buf;
}
+#include "sp5x.h"
+
+static int sp5x_decode_frame(AVCodecContext *avctx,
+ void *data, int *data_size,
+ uint8_t *buf, int buf_size)
+{
+#if 0
+ MJpegDecodeContext *s = avctx->priv_data;
+#endif
+ const int qscale = 5;
+ uint8_t *buf_ptr, *buf_end, *recoded;
+ int i = 0, j = 0;
+
+ *data_size = 0;
+
+ /* no supplementary picture */
+ if (buf_size == 0)
+ return 0;
+
+ if (!avctx->width || !avctx->height)
+ return -1;
+
+ buf_ptr = buf;
+ buf_end = buf + buf_size;
+
+#if 1
+ recoded = av_mallocz(buf_size + 1024);
+ if (!recoded)
+ return -1;
+
+ /* SOI */
+ recoded[j++] = 0xFF;
+ recoded[j++] = 0xD8;
+
+ memcpy(recoded+j, &sp5x_data_dqt[0], sizeof(sp5x_data_dqt));
+ memcpy(recoded+j+5, &sp5x_quant_table[qscale * 2], 64);
+ memcpy(recoded+j+70, &sp5x_quant_table[(qscale * 2) + 1], 64);
+ j += sizeof(sp5x_data_dqt);
+
+ memcpy(recoded+j, &sp5x_data_dht[0], sizeof(sp5x_data_dht));
+ j += sizeof(sp5x_data_dht);
+
+ memcpy(recoded+j, &sp5x_data_sof[0], sizeof(sp5x_data_sof));
+ recoded[j+5] = (avctx->height >> 8) & 0xFF;
+ recoded[j+6] = avctx->height & 0xFF;
+ recoded[j+7] = (avctx->width >> 8) & 0xFF;
+ recoded[j+8] = avctx->width & 0xFF;
+ j += sizeof(sp5x_data_sof);
+
+ memcpy(recoded+j, &sp5x_data_sos[0], sizeof(sp5x_data_sos));
+ j += sizeof(sp5x_data_sos);
+
+ for (i = 14; i < buf_size && j < buf_size+1024-2; i++)
+ {
+ recoded[j++] = buf[i];
+ if (buf[i] == 0xff)
+ recoded[j++] = 0;
+ }
+
+ /* EOI */
+ recoded[j++] = 0xFF;
+ recoded[j++] = 0xD9;
+
+ i = mjpeg_decode_frame(avctx, data, data_size, recoded, j);
+
+ av_free(recoded);
+
+#else
+ /* SOF */
+ s->bits = 8;
+ s->width = avctx->width;
+ s->height = avctx->height;
+ s->nb_components = 3;
+ s->component_id[0] = 0;
+ s->h_count[0] = 2;
+ s->v_count[0] = 2;
+ s->quant_index[0] = 0;
+ s->component_id[1] = 1;
+ s->h_count[1] = 1;
+ s->v_count[1] = 1;
+ s->quant_index[1] = 1;
+ s->component_id[2] = 2;
+ s->h_count[2] = 1;
+ s->v_count[2] = 1;
+ s->quant_index[2] = 1;
+ s->h_max = 2;
+ s->v_max = 2;
+
+ s->qscale_table = av_mallocz((s->width+15)/16);
+ avctx->pix_fmt = PIX_FMT_YUV420P;
+ s->interlaced = 0;
+
+ s->picture.reference = 0;
+ if (avctx->get_buffer(avctx, &s->picture) < 0)
+ {
+ fprintf(stderr, "get_buffer() failed\n");
+ return -1;
+ }
+
+ s->picture.pict_type = I_TYPE;
+ s->picture.key_frame = 1;
+
+ for (i = 0; i < 3; i++)
+ s->linesize[i] = s->picture.linesize[i] << s->interlaced;
+
+ /* DQT */
+ for (i = 0; i < 64; i++)
+ {
+ j = s->scantable.permutated[i];
+ s->quant_matrixes[0][j] = sp5x_quant_table[(qscale * 2) + i];
+ }
+ s->qscale[0] = FFMAX(
+ s->quant_matrixes[0][s->scantable.permutated[1]],
+ s->quant_matrixes[0][s->scantable.permutated[8]]) >> 1;
+
+ for (i = 0; i < 64; i++)
+ {
+ j = s->scantable.permutated[i];
+ s->quant_matrixes[1][j] = sp5x_quant_table[(qscale * 2) + 1 + i];
+ }
+ s->qscale[1] = FFMAX(
+ s->quant_matrixes[1][s->scantable.permutated[1]],
+ s->quant_matrixes[1][s->scantable.permutated[8]]) >> 1;
+
+ /* DHT */
+
+ /* SOS */
+ s->comp_index[0] = 0;
+ s->nb_blocks[0] = s->h_count[0] * s->v_count[0];
+ s->h_scount[0] = s->h_count[0];
+ s->v_scount[0] = s->v_count[0];
+ s->dc_index[0] = 0;
+ s->ac_index[0] = 0;
+
+ s->comp_index[1] = 1;
+ s->nb_blocks[1] = s->h_count[1] * s->v_count[1];
+ s->h_scount[1] = s->h_count[1];
+ s->v_scount[1] = s->v_count[1];
+ s->dc_index[1] = 1;
+ s->ac_index[1] = 1;
+
+ s->comp_index[2] = 2;
+ s->nb_blocks[2] = s->h_count[2] * s->v_count[2];
+ s->h_scount[2] = s->h_count[2];
+ s->v_scount[2] = s->v_count[2];
+ s->dc_index[2] = 1;
+ s->ac_index[2] = 1;
+
+ for (i = 0; i < 3; i++)
+ s->last_dc[i] = 1024;
+
+ s->mb_width = (s->width * s->h_max * 8 -1) / (s->h_max * 8);
+ s->mb_height = (s->height * s->v_max * 8 -1) / (s->v_max * 8);
+
+ init_get_bits(&s->gb, buf, buf_size*8);
+
+ return mjpeg_decode_scan(s);
+#endif
+
+ return i;
+}
static int mjpeg_decode_end(AVCodecContext *avctx)
{
@@ -2003,8 +2162,9 @@ static int mjpeg_decode_end(AVCodecContext *avctx)
int i, j;
av_free(s->buffer);
- for(i=0;i<MAX_COMPONENTS;i++)
- av_free(s->current_picture[i]);
+ av_free(s->qscale_table);
+ avcodec_default_free_buffers(avctx);
+
for(i=0;i<2;i++) {
for(j=0;j<4;j++)
free_vlc(&s->vlcs[i][j]);
@@ -2021,7 +2181,7 @@ AVCodec mjpeg_decoder = {
NULL,
mjpeg_decode_end,
mjpeg_decode_frame,
- 0,
+ CODEC_CAP_DR1,
NULL
};
@@ -2034,10 +2194,24 @@ AVCodec mjpegb_decoder = {
NULL,
mjpeg_decode_end,
mjpegb_decode_frame,
- 0,
+ CODEC_CAP_DR1,
NULL
};
+AVCodec sp5x_decoder = {
+ "sp5x",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_SP5X,
+ sizeof(MJpegDecodeContext),
+ mjpeg_decode_init,
+ NULL,
+ mjpeg_decode_end,
+ sp5x_decode_frame,
+ CODEC_CAP_DR1,
+ NULL
+};
+
+#ifdef CONFIG_ENCODERS
AVCodec ljpeg_encoder = { //FIXME avoid MPV_* lossless jpeg shouldnt need them
"ljpeg",
CODEC_TYPE_VIDEO,
@@ -2047,3 +2221,4 @@ AVCodec ljpeg_encoder = { //FIXME avoid MPV_* lossless jpeg shouldnt need them
encode_picture_lossless,
MPV_encode_end,
};
+#endif
diff --git a/src/libffmpeg/libavcodec/mlib/dsputil_mlib.c b/src/libffmpeg/libavcodec/mlib/dsputil_mlib.c
index 19c9e6c19..6cd8bfe97 100644
--- a/src/libffmpeg/libavcodec/mlib/dsputil_mlib.c
+++ b/src/libffmpeg/libavcodec/mlib/dsputil_mlib.c
@@ -407,6 +407,11 @@ static void ff_idct_add_mlib(uint8_t *dest, int line_size, DCTELEM *data)
mlib_VideoAddBlock_U8_S16(dest, (mlib_s16 *)data, line_size);
}
+static void ff_idct_mlib(uint8_t *dest, int line_size, DCTELEM *data)
+{
+ mlib_VideoIDCT8x8_S16_S16 (data, data);
+}
+
static void ff_fdct_mlib(DCTELEM *data)
{
mlib_VideoDCT8x8_S16_S16 (data, data);
@@ -452,8 +457,9 @@ void MPV_common_init_mlib(MpegEncContext *s)
}
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_put= ff_idct_put_mlib;
+ s->dsp.idct_add= ff_idct_add_mlib;
+ s->dsp.idct = ff_idct_mlib;
s->dsp.idct_permutation_type= FF_NO_IDCT_PERM;
}
}
diff --git a/src/libffmpeg/libavcodec/motion_est.c b/src/libffmpeg/libavcodec/motion_est.c
index 58b96d489..52774d392 100644
--- a/src/libffmpeg/libavcodec/motion_est.c
+++ b/src/libffmpeg/libavcodec/motion_est.c
@@ -28,6 +28,7 @@
#include <stdlib.h>
#include <stdio.h>
+#include <limits.h>
#include "avcodec.h"
#include "dsputil.h"
#include "mpegvideo.h"
@@ -393,6 +394,7 @@ void ff_init_me(MpegEncContext *s){
}
}
+#if 0
static int pix_dev(uint8_t * pix, int line_size, int mean)
{
int s, i, j;
@@ -414,6 +416,7 @@ static int pix_dev(uint8_t * pix, int line_size, int mean)
}
return s;
}
+#endif
static inline void no_motion_search(MpegEncContext * s,
int *mx_ptr, int *my_ptr)
@@ -809,13 +812,8 @@ static inline void get_limits(MpegEncContext *s, int *range, int *xmin, int *ymi
if (s->unrestricted_mv) {
*xmin = -16;
*ymin = -16;
- if(s->avctx->codec->id!=CODEC_ID_MPEG4){
- *xmax = s->mb_width*16;
- *ymax = s->mb_height*16;
- }else {
- *xmax = s->width;
- *ymax = s->height;
- }
+ *xmax = s->mb_width*16;
+ *ymax = s->mb_height*16;
} else {
*xmin = 0;
*ymin = 0;
@@ -832,6 +830,7 @@ static inline int h263_mv4_search(MpegEncContext *s, int xmin, int ymin, int xma
int P[10][2];
int dmin_sum=0, mx4_sum=0, my4_sum=0;
uint8_t * const mv_penalty= s->me.mv_penalty[s->f_code] + MAX_MV;
+ int same=1;
for(block=0; block<4; block++){
int mx4, my4;
@@ -930,8 +929,13 @@ static inline int h263_mv4_search(MpegEncContext *s, int xmin, int ymin, int xma
s->motion_val[ s->block_index[block] ][0]= mx4;
s->motion_val[ s->block_index[block] ][1]= my4;
+
+ if(mx4 != mx || my4 != my) same=0;
}
+ if(same)
+ return INT_MAX;
+
if(s->dsp.me_sub_cmp[0] != s->dsp.mb_cmp[0]){
dmin_sum += s->dsp.mb_cmp[0](s, s->new_picture.data[0] + s->mb_x*16 + s->mb_y*16*s->linesize, s->me.scratchpad, s->linesize);
}
@@ -1088,7 +1092,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
printf("varc=%4d avg_var=%4d (sum=%4d) vard=%4d mx=%2d my=%2d\n",
varc, s->avg_mb_var, sum, vard, mx - xx, my - yy);
#endif
- if(s->flags&CODEC_FLAG_HQ){
+ if(s->avctx->mb_decision > FF_MB_DECISION_SIMPLE){
if (vard <= 64 || vard < varc)
s->scene_change_score+= ff_sqrt(vard) - ff_sqrt(varc);
else
@@ -1100,14 +1104,17 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
mb_type|= MB_TYPE_INTER;
s->me.sub_motion_search(s, &mx, &my, dmin, rel_xmin, rel_ymin, rel_xmax, rel_ymax,
pred_x, pred_y, &s->last_picture, 0, 0, mv_penalty);
+ if(s->flags&CODEC_FLAG_MV0)
+ if(mx || my)
+ mb_type |= MB_TYPE_SKIPED; //FIXME check difference
}else{
mx <<=shift;
my <<=shift;
}
if((s->flags&CODEC_FLAG_4MV)
&& !s->me.skip && varc>50 && vard>10){
- h263_mv4_search(s, rel_xmin, rel_ymin, rel_xmax, rel_ymax, mx, my, shift);
- mb_type|=MB_TYPE_INTER4V;
+ if(h263_mv4_search(s, rel_xmin, rel_ymin, rel_xmax, rel_ymax, mx, my, shift) < INT_MAX)
+ mb_type|=MB_TYPE_INTER4V;
set_p_mv_tables(s, mx, my, 0);
}else
@@ -1320,8 +1327,8 @@ static inline int check_bidir_mv(MpegEncContext * s,
dxy = ((motion_fy & 3) << 2) | (motion_fx & 3);
src_x = mb_x * 16 + (motion_fx >> 2);
src_y = mb_y * 16 + (motion_fy >> 2);
- assert(src_x >=-16 && src_x<=s->width);
- assert(src_y >=-16 && src_y<=s->height);
+ assert(src_x >=-16 && src_x<=s->h_edge_pos);
+ assert(src_y >=-16 && src_y<=s->v_edge_pos);
ptr = s->last_picture.data[0] + (src_y * s->linesize) + src_x;
s->dsp.put_qpel_pixels_tab[0][dxy](dest_y , ptr , s->linesize);
@@ -1329,8 +1336,8 @@ static inline int check_bidir_mv(MpegEncContext * s,
dxy = ((motion_by & 3) << 2) | (motion_bx & 3);
src_x = mb_x * 16 + (motion_bx >> 2);
src_y = mb_y * 16 + (motion_by >> 2);
- assert(src_x >=-16 && src_x<=s->width);
- assert(src_y >=-16 && src_y<=s->height);
+ assert(src_x >=-16 && src_x<=s->h_edge_pos);
+ assert(src_y >=-16 && src_y<=s->v_edge_pos);
ptr = s->next_picture.data[0] + (src_y * s->linesize) + src_x;
s->dsp.avg_qpel_pixels_tab[0][dxy](dest_y , ptr , s->linesize);
@@ -1338,8 +1345,8 @@ static inline int check_bidir_mv(MpegEncContext * s,
dxy = ((motion_fy & 1) << 1) | (motion_fx & 1);
src_x = mb_x * 16 + (motion_fx >> 1);
src_y = mb_y * 16 + (motion_fy >> 1);
- assert(src_x >=-16 && src_x<=s->width);
- assert(src_y >=-16 && src_y<=s->height);
+ assert(src_x >=-16 && src_x<=s->h_edge_pos);
+ assert(src_y >=-16 && src_y<=s->v_edge_pos);
ptr = s->last_picture.data[0] + (src_y * s->linesize) + src_x;
s->dsp.put_pixels_tab[0][dxy](dest_y , ptr , s->linesize, 16);
@@ -1347,8 +1354,8 @@ static inline int check_bidir_mv(MpegEncContext * s,
dxy = ((motion_by & 1) << 1) | (motion_bx & 1);
src_x = mb_x * 16 + (motion_bx >> 1);
src_y = mb_y * 16 + (motion_by >> 1);
- assert(src_x >=-16 && src_x<=s->width);
- assert(src_y >=-16 && src_y<=s->height);
+ assert(src_x >=-16 && src_x<=s->h_edge_pos);
+ assert(src_y >=-16 && src_y<=s->v_edge_pos);
ptr = s->next_picture.data[0] + (src_y * s->linesize) + src_x;
s->dsp.avg_pixels_tab[0][dxy](dest_y , ptr , s->linesize, 16);
@@ -1497,20 +1504,27 @@ void ff_estimate_b_frame_motion(MpegEncContext * s,
int fmin, bmin, dmin, fbmin;
int type=0;
- dmin= direct_search(s, mb_x, mb_y);
+ s->me.skip=0;
+ if (s->codec_id == CODEC_ID_MPEG4)
+ dmin= direct_search(s, mb_x, mb_y);
+ else
+ dmin= INT_MAX;
+ s->me.skip=0;
fmin= ff_estimate_motion_b(s, mb_x, mb_y, s->b_forw_mv_table, &s->last_picture, s->f_code) + 3*penalty_factor;
+
+ s->me.skip=0;
bmin= ff_estimate_motion_b(s, mb_x, mb_y, s->b_back_mv_table, &s->next_picture, s->b_code) + 2*penalty_factor;
//printf(" %d %d ", s->b_forw_mv_table[xy][0], s->b_forw_mv_table[xy][1]);
+ s->me.skip=0;
fbmin= bidir_refine(s, mb_x, mb_y) + penalty_factor;
//printf("%d %d %d %d\n", dmin, fmin, bmin, fbmin);
{
int score= fmin;
type = MB_TYPE_FORWARD;
- // RAL: No MB_TYPE_DIRECT in MPEG-1 video (only MPEG-4)
- if (s->codec_id != CODEC_ID_MPEG1VIDEO && dmin <= score){
+ if (dmin <= score){
score = dmin;
type = MB_TYPE_DIRECT;
}
@@ -1528,7 +1542,7 @@ void ff_estimate_b_frame_motion(MpegEncContext * s,
s->current_picture.mc_mb_var[mb_y*s->mb_stride + mb_x] = score; //FIXME use SSE
}
- if(s->flags&CODEC_FLAG_HQ){
+ if(s->avctx->mb_decision > FF_MB_DECISION_SIMPLE){
type= MB_TYPE_FORWARD | MB_TYPE_BACKWARD | MB_TYPE_BIDIR | MB_TYPE_DIRECT; //FIXME something smarter
if(dmin>256*256*16) type&= ~MB_TYPE_DIRECT; //dont try direct mode if its invalid for this MB
}
@@ -1589,8 +1603,9 @@ void ff_fix_long_p_mvs(MpegEncContext * s)
{
const int f_code= s->f_code;
int y, range;
+ assert(s->pict_type==P_TYPE);
- range = (((s->codec_id == CODEC_ID_MPEG1VIDEO) ? 8 : 16) << f_code);
+ range = (((s->out_format == FMT_MPEG1) ? 8 : 16) << f_code);
if(s->msmpeg4_version) range= 16;
@@ -1650,7 +1665,7 @@ void ff_fix_long_b_mvs(MpegEncContext * s, int16_t (*mv_table)[2], int f_code, i
int y;
// RAL: 8 in MPEG-1, 16 in MPEG-4
- int range = (((s->codec_id == CODEC_ID_MPEG1VIDEO) ? 8 : 16) << f_code);
+ int range = (((s->out_format == FMT_MPEG1) ? 8 : 16) << f_code);
if(s->avctx->me_range && range > s->avctx->me_range) range= s->avctx->me_range;
diff --git a/src/libffmpeg/libavcodec/motion_est_template.c b/src/libffmpeg/libavcodec/motion_est_template.c
index 546509e53..db51d676d 100644
--- a/src/libffmpeg/libavcodec/motion_est_template.c
+++ b/src/libffmpeg/libavcodec/motion_est_template.c
@@ -186,7 +186,9 @@ static int RENAME(hpel_motion_search)(MpegEncContext * s,
#if 1
int key;
int map_generation= s->me.map_generation;
+#ifndef NDEBUG
uint32_t *map= s->me.map;
+#endif
key= ((my-1)<<ME_MAP_MV_BITS) + (mx) + map_generation;
assert(map[(index-(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1)] == key);
key= ((my+1)<<ME_MAP_MV_BITS) + (mx) + map_generation;
diff --git a/src/libffmpeg/libavcodec/mpeg12.c b/src/libffmpeg/libavcodec/mpeg12.c
index c68f8d8a0..cd3a725ae 100644
--- a/src/libffmpeg/libavcodec/mpeg12.c
+++ b/src/libffmpeg/libavcodec/mpeg12.c
@@ -19,7 +19,7 @@
/**
* @file mpeg12.c
- * MPEG1 codec / MPEG2 decoder.
+ * MPEG1/2 codec
*/
//#define DEBUG
@@ -48,10 +48,12 @@
#define MB_BTYPE_VLC_BITS 6
#define TEX_VLC_BITS 9
+#ifdef CONFIG_ENCODERS
static void mpeg1_encode_block(MpegEncContext *s,
DCTELEM *block,
int component);
static void mpeg1_encode_motion(MpegEncContext *s, int val, int f_or_b_code); // RAL: f_code parameter added
+#endif //CONFIG_ENCODERS
static void mpeg1_skip_picture(MpegEncContext *s, int pict_num);
static inline int mpeg1_decode_block_inter(MpegEncContext *s,
DCTELEM *block,
@@ -67,13 +69,25 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s,
int n);
static int mpeg_decode_motion(MpegEncContext *s, int fcode, int pred);
+#ifdef HAVE_XVMC
+extern int XVMC_field_start(MpegEncContext *s, AVCodecContext *avctx);
+extern int XVMC_field_end(MpegEncContext *s);
+#endif
+
#ifdef CONFIG_ENCODERS
static uint8_t (*mv_penalty)[MAX_MV*2+1]= NULL;
static uint8_t fcode_tab[MAX_MV*2+1];
static uint32_t uni_mpeg1_ac_vlc_bits[64*64*2];
static uint8_t uni_mpeg1_ac_vlc_len [64*64*2];
-#endif
+
+/* simple include everything table for dc, first byte is bits number next 3 are code*/
+static uint32_t mpeg1_lum_dc_uni[512];
+static uint32_t mpeg1_chr_dc_uni[512];
+
+static uint8_t mpeg1_index_run[2][64];
+static int8_t mpeg1_max_level[2][64];
+#endif //CONFIG_ENCODERS
static void init_2d_vlc_rl(RLTable *rl)
{
@@ -114,6 +128,7 @@ static void init_2d_vlc_rl(RLTable *rl)
}
}
+#ifdef CONFIG_ENCODERS
static void init_uni_ac_vlc(RLTable *rl, uint32_t *uni_ac_vlc_bits, uint8_t *uni_ac_vlc_len){
int i;
@@ -175,9 +190,10 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
int n, i;
uint64_t time_code;
float best_aspect_error= 1E10;
- float aspect_ratio= s->avctx->aspect_ratio;
+ float aspect_ratio= av_q2d(s->avctx->sample_aspect_ratio);
+ int constraint_parameter_flag;
- if(aspect_ratio==0.0) aspect_ratio= s->width / (float)s->height; //pixel aspect 1:1 (VGA)
+ if(aspect_ratio==0.0) aspect_ratio= 1.0; //pixel aspect 1:1 (VGA)
if (s->current_picture.key_frame) {
/* mpeg1 header repeated every gop */
@@ -203,7 +219,12 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
put_bits(&s->pb, 12, s->height);
for(i=1; i<15; i++){
- float error= mpeg1_aspect[i] - s->width/(s->height*aspect_ratio);
+ float error= aspect_ratio;
+ if(s->codec_id == CODEC_ID_MPEG1VIDEO || i <=1)
+ error-= mpeg1_aspect[i];
+ else
+ error-= av_q2d(mpeg2_aspect[i])*s->height/s->width;
+
error= ABS(error);
if(error < best_aspect_error){
@@ -214,22 +235,58 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
put_bits(&s->pb, 4, s->aspect_ratio_info);
put_bits(&s->pb, 4, s->frame_rate_index);
- v = (s->bit_rate + 399) / 400;
- if (v > 0x3ffff)
- v = 0x3ffff;
- put_bits(&s->pb, 18, v);
- put_bits(&s->pb, 1, 1); /* marker */
+
+ if(s->avctx->rc_max_rate){
+ v = (s->avctx->rc_max_rate + 399) / 400;
+ if (v > 0x3ffff && s->codec_id == CODEC_ID_MPEG1VIDEO)
+ v = 0x3ffff;
+ }else{
+ v= 0x3FFFF;
+ }
if(s->avctx->rc_buffer_size)
vbv_buffer_size = s->avctx->rc_buffer_size;
else
/* VBV calculation: Scaled so that a VCD has the proper VBV size of 40 kilobytes */
- vbv_buffer_size = (( 20 * s->bit_rate) / (1151929 / 2)) * 8 * 1024;
- put_bits(&s->pb, 10, (vbv_buffer_size + 16383) / 16384);
- put_bits(&s->pb, 1, 1); /* constrained parameter flag */
- put_bits(&s->pb, 1, 0); /* no custom intra matrix */
- put_bits(&s->pb, 1, 0); /* no custom non intra matrix */
+ vbv_buffer_size = (( 20 * s->bit_rate) / (1151929 / 2)) * 8 * 1024;
+ vbv_buffer_size= (vbv_buffer_size + 16383) / 16384;
+ put_bits(&s->pb, 18, v & 0x3FFFF);
+ put_bits(&s->pb, 1, 1); /* marker */
+ put_bits(&s->pb, 10, vbv_buffer_size & 0x3FF);
+
+ constraint_parameter_flag=
+ s->width <= 768 && s->height <= 576 &&
+ s->mb_width * s->mb_height <= 396 &&
+ s->mb_width * s->mb_height * frame_rate_tab[s->frame_rate_index] <= MPEG1_FRAME_RATE_BASE*396*25 &&
+ frame_rate_tab[s->frame_rate_index] <= MPEG1_FRAME_RATE_BASE*30 &&
+ vbv_buffer_size <= 20 &&
+ v <= 1856000/400 &&
+ s->codec_id == CODEC_ID_MPEG1VIDEO;
+
+ put_bits(&s->pb, 1, constraint_parameter_flag);
+
+ ff_write_quant_matrix(&s->pb, s->avctx->intra_matrix);
+ ff_write_quant_matrix(&s->pb, s->avctx->inter_matrix);
+
+ if(s->codec_id == CODEC_ID_MPEG2VIDEO){
+ put_header(s, EXT_START_CODE);
+ put_bits(&s->pb, 4, 1); //seq ext
+ put_bits(&s->pb, 1, 0); //esc
+ put_bits(&s->pb, 3, 4); //profile
+ put_bits(&s->pb, 4, 8); //level
+ put_bits(&s->pb, 1, s->progressive_sequence=1);
+ put_bits(&s->pb, 2, 1); //chroma format 4:2:0
+ put_bits(&s->pb, 2, 0); //horizontal size ext
+ put_bits(&s->pb, 2, 0); //vertical size ext
+ put_bits(&s->pb, 12, v>>18); //bitrate ext
+ put_bits(&s->pb, 1, 1); //marker
+ put_bits(&s->pb, 8, vbv_buffer_size >>10); //vbv buffer ext
+ put_bits(&s->pb, 1, s->low_delay);
+ put_bits(&s->pb, 2, 0); // frame_rate_ext_n
+ put_bits(&s->pb, 5, 0); // frame_rate_ext_d
+ }
+
put_header(s, GOP_START_CODE);
put_bits(&s->pb, 1, 0); /* do drop frame */
/* time code : we must convert from the real frame rate to a
@@ -242,7 +299,7 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
put_bits(&s->pb, 1, 1);
put_bits(&s->pb, 6, (uint32_t)((time_code / fps) % 60));
put_bits(&s->pb, 6, (uint32_t)((time_code % fps) / MPEG1_FRAME_RATE_BASE));
- put_bits(&s->pb, 1, 1); /* closed gop */
+ put_bits(&s->pb, 1, 0); /* closed gop */
put_bits(&s->pb, 1, 0); /* broken link */
}
@@ -272,6 +329,8 @@ static inline void encode_mb_skip_run(MpegEncContext *s, int run){
/* insert a fake P picture */
static void mpeg1_skip_picture(MpegEncContext *s, int pict_num)
{
+ assert(s->codec_id == CODEC_ID_MPEG1VIDEO); // mpeg2 can do these repeat things
+
/* mpeg1 picture header */
put_header(s, PICTURE_START_CODE);
/* temporal reference */
@@ -309,6 +368,7 @@ static void mpeg1_skip_picture(MpegEncContext *s, int pict_num)
put_bits(&s->pb, 1, 1);
put_bits(&s->pb, 1, 1);
}
+#endif //CONFIG_ENCODERS
static void common_init(MpegEncContext *s)
{
@@ -316,6 +376,13 @@ 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){
@@ -324,13 +391,6 @@ 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);
@@ -350,17 +410,52 @@ void mpeg1_encode_picture_header(MpegEncContext *s, int picture_number)
// RAL: Forward f_code also needed for B frames
if (s->pict_type == P_TYPE || s->pict_type == B_TYPE) {
put_bits(&s->pb, 1, 0); /* half pel coordinates */
- put_bits(&s->pb, 3, s->f_code); /* forward_f_code */
+ if(s->codec_id == CODEC_ID_MPEG1VIDEO)
+ put_bits(&s->pb, 3, s->f_code); /* forward_f_code */
+ else
+ put_bits(&s->pb, 3, 7); /* forward_f_code */
}
// RAL: Backward f_code necessary for B frames
if (s->pict_type == B_TYPE) {
put_bits(&s->pb, 1, 0); /* half pel coordinates */
- put_bits(&s->pb, 3, s->b_code); /* backward_f_code */
- }
+ if(s->codec_id == CODEC_ID_MPEG1VIDEO)
+ put_bits(&s->pb, 3, s->b_code); /* backward_f_code */
+ else
+ put_bits(&s->pb, 3, 7); /* backward_f_code */
+ }
put_bits(&s->pb, 1, 0); /* extra bit picture */
+ if(s->codec_id == CODEC_ID_MPEG2VIDEO){
+ put_header(s, EXT_START_CODE);
+ put_bits(&s->pb, 4, 8); //pic ext
+ if (s->pict_type == P_TYPE || s->pict_type == B_TYPE) {
+ put_bits(&s->pb, 4, s->f_code);
+ put_bits(&s->pb, 4, s->f_code);
+ }else{
+ put_bits(&s->pb, 8, 255);
+ }
+ if (s->pict_type == B_TYPE) {
+ put_bits(&s->pb, 4, s->b_code);
+ put_bits(&s->pb, 4, s->b_code);
+ }else{
+ put_bits(&s->pb, 8, 255);
+ }
+ put_bits(&s->pb, 2, s->intra_dc_precision);
+ put_bits(&s->pb, 2, s->picture_structure= PICT_FRAME);
+ put_bits(&s->pb, 1, s->top_field_first);
+ put_bits(&s->pb, 1, s->frame_pred_frame_dct= 1);
+ put_bits(&s->pb, 1, s->concealment_motion_vectors);
+ put_bits(&s->pb, 1, s->q_scale_type);
+ put_bits(&s->pb, 1, s->intra_vlc_format);
+ put_bits(&s->pb, 1, s->alternate_scan);
+ put_bits(&s->pb, 1, s->repeat_first_field);
+ put_bits(&s->pb, 1, s->chroma_420_type=1);
+ put_bits(&s->pb, 1, s->progressive_frame=1);
+ put_bits(&s->pb, 1, 0); //composite_display_flag
+ }
+
s->mb_y=0;
ff_mpeg1_encode_slice_header(s);
}
@@ -381,7 +476,7 @@ void mpeg1_encode_mb(MpegEncContext *s,
cbp |= 1 << (5 - i);
}
- if (cbp == 0 && !first_mb && (mb_x != s->mb_width - 1 || mb_y != s->mb_height - 1) &&
+ if (cbp == 0 && !first_mb && (mb_x != s->mb_width - 1 || (mb_y != s->mb_height - 1 && s->codec_id == CODEC_ID_MPEG1VIDEO)) &&
((s->pict_type == P_TYPE && (motion_x | motion_y) == 0) ||
(s->pict_type == B_TYPE && s->mv_dir == s->last_mv_dir && (((s->mv_dir & MV_DIR_FORWARD) ? ((s->mv[0][0][0] - s->last_mv[0][0][0])|(s->mv[0][0][1] - s->last_mv[0][0][1])) : 0) |
((s->mv_dir & MV_DIR_BACKWARD) ? ((s->mv[1][0][0] - s->last_mv[1][0][0])|(s->mv[1][0][1] - s->last_mv[1][0][1])) : 0)) == 0))) {
@@ -693,10 +788,17 @@ void ff_mpeg1_encode_init(MpegEncContext *s)
}
s->me.mv_penalty= mv_penalty;
s->fcode_tab= fcode_tab;
- s->min_qcoeff=-255;
- s->max_qcoeff= 255;
+ if(s->codec_id == CODEC_ID_MPEG1VIDEO){
+ s->min_qcoeff=-255;
+ s->max_qcoeff= 255;
+ }else{
+ s->min_qcoeff=-2047;
+ s->max_qcoeff= 2047;
+ }
s->intra_ac_vlc_length=
- s->inter_ac_vlc_length= uni_mpeg1_ac_vlc_len;
+ s->inter_ac_vlc_length=
+ s->intra_ac_vlc_last_length=
+ s->inter_ac_vlc_last_length= uni_mpeg1_ac_vlc_len;
}
static inline void encode_dc(MpegEncContext *s, int diff, int component)
@@ -732,6 +834,12 @@ static void mpeg1_encode_block(MpegEncContext *s,
encode_dc(s, diff, component);
s->last_dc[component] = dc;
i = 1;
+/*
+ if (s->intra_vlc_format)
+ rl = &rl_mpeg2;
+ else
+ rl = &rl_mpeg1;
+*/
} else {
/* encode the first coefficient : needs to be done here because
it is handled slightly differently */
@@ -776,14 +884,18 @@ static void mpeg1_encode_block(MpegEncContext *s,
put_bits(&s->pb, mpeg1_vlc[111/*rl->n*/][1], mpeg1_vlc[111/*rl->n*/][0]);
/* escape: only clip in this case */
put_bits(&s->pb, 6, run);
- if (alevel < 128) {
- put_bits(&s->pb, 8, level & 0xff);
- } else {
- if (level < 0) {
- put_bits(&s->pb, 16, 0x8001 + level + 255);
+ if(s->codec_id == CODEC_ID_MPEG1VIDEO){
+ if (alevel < 128) {
+ put_bits(&s->pb, 8, level & 0xff);
} else {
- put_bits(&s->pb, 16, level & 0xffff);
+ if (level < 0) {
+ put_bits(&s->pb, 16, 0x8001 + level + 255);
+ } else {
+ put_bits(&s->pb, 16, level & 0xffff);
+ }
}
+ }else{
+ put_bits(&s->pb, 12, level & 0xfff);
}
}
last_non_zero = i;
@@ -805,7 +917,7 @@ static VLC mb_ptype_vlc;
static VLC mb_btype_vlc;
static VLC mb_pat_vlc;
-static void init_vlcs(MpegEncContext *s)
+static void init_vlcs()
{
static int done = 0;
@@ -853,7 +965,7 @@ static inline int get_dmv(MpegEncContext *s)
static inline int get_qscale(MpegEncContext *s)
{
int qscale = get_bits(&s->gb, 5);
- if (s->mpeg2) {
+ if (s->codec_id == CODEC_ID_MPEG2VIDEO) {
if (s->q_scale_type) {
return non_linear_qscale[qscale];
} else {
@@ -919,8 +1031,10 @@ static int mpeg_decode_mb(MpegEncContext *s,
default:
case I_TYPE:
if (get_bits1(&s->gb) == 0) {
- if (get_bits1(&s->gb) == 0)
+ if (get_bits1(&s->gb) == 0){
+ fprintf(stderr, "invalid mb type in I Frame at %d %d\n", s->mb_x, s->mb_y);
return -1;
+ }
mb_type = MB_TYPE_QUANT | MB_TYPE_INTRA;
} else {
mb_type = MB_TYPE_INTRA;
@@ -959,14 +1073,18 @@ static int mpeg_decode_mb(MpegEncContext *s,
/* just parse them */
if (s->picture_structure != PICT_FRAME)
skip_bits1(&s->gb); /* field select */
- mpeg_decode_motion(s, s->mpeg_f_code[0][0], 0);
- mpeg_decode_motion(s, s->mpeg_f_code[0][1], 0);
+
+ s->mv[0][0][0]= s->last_mv[0][0][0]= s->last_mv[0][1][0] =
+ mpeg_decode_motion(s, s->mpeg_f_code[0][0], s->last_mv[0][0][0]);
+ s->mv[0][0][1]= s->last_mv[0][0][1]= s->last_mv[0][1][1] =
+ mpeg_decode_motion(s, s->mpeg_f_code[0][1], s->last_mv[0][0][1]);
+
skip_bits1(&s->gb); /* marker */
- }
+ }else
+ memset(s->last_mv, 0, sizeof(s->last_mv)); /* reset mv prediction */
s->mb_intra = 1;
- memset(s->last_mv, 0, sizeof(s->last_mv)); /* reset mv prediction */
- if (s->mpeg2) {
+ if (s->codec_id == CODEC_ID_MPEG2VIDEO) {
for(i=0;i<6;i++) {
if (mpeg2_decode_block_intra(s, block[i], i) < 0)
return -1;
@@ -1095,34 +1213,37 @@ static int mpeg_decode_mb(MpegEncContext *s,
s->last_mv[i][0][1] >> 1);
dmy = get_dmv(s);
s->mv_type = MV_TYPE_DMV;
- /* XXX: totally broken */
+
+
+ s->last_mv[i][0][1] = my<<1;
+ s->last_mv[i][1][1] = my<<1;
+
+ s->mv[i][0][0] = mx;
+ s->mv[i][0][1] = my;
+ s->mv[i][1][0] = mx;//not used
+ s->mv[i][1][1] = my;//not used
+
if (s->picture_structure == PICT_FRAME) {
mb_type |= MB_TYPE_16x16 | MB_TYPE_INTERLACED;
- s->last_mv[i][0][1] = my << 1;
- s->last_mv[i][1][1] = my << 1;
-
+ //m = 1 + 2 * s->top_field_first;
m = s->top_field_first ? 1 : 3;
+
/* top -> top pred */
- s->mv[i][0][0] = mx;
- s->mv[i][0][1] = my << 1;
- s->mv[i][1][0] = ((mx * m + (mx > 0)) >> 1) + dmx;
- s->mv[i][1][1] = ((my * m + (my > 0)) >> 1) + dmy - 1;
+ s->mv[i][2][0] = ((mx * m + (mx > 0)) >> 1) + dmx;
+ s->mv[i][2][1] = ((my * m + (my > 0)) >> 1) + dmy - 1;
m = 4 - m;
- s->mv[i][2][0] = mx;
- s->mv[i][2][1] = my << 1;
s->mv[i][3][0] = ((mx * m + (mx > 0)) >> 1) + dmx;
s->mv[i][3][1] = ((my * m + (my > 0)) >> 1) + dmy + 1;
} else {
mb_type |= MB_TYPE_16x16;
- s->last_mv[i][0][1] = my;
- s->last_mv[i][1][1] = my;
- s->mv[i][0][0] = mx;
- s->mv[i][0][1] = my;
- s->mv[i][1][0] = ((mx + (mx > 0)) >> 1) + dmx;
- s->mv[i][1][1] = ((my + (my > 0)) >> 1) + dmy - 1
- /* + 2 * cur_field */;
+ s->mv[i][2][0] = ((mx + (mx > 0)) >> 1) + dmx;
+ s->mv[i][2][1] = ((my + (my > 0)) >> 1) + dmy;
+ if(s->picture_structure == PICT_TOP_FIELD)
+ s->mv[i][2][1]--;
+ else
+ s->mv[i][2][1]++;
}
}
break;
@@ -1141,7 +1262,7 @@ static int mpeg_decode_mb(MpegEncContext *s,
}
cbp++;
- if (s->mpeg2) {
+ if (s->codec_id == CODEC_ID_MPEG2VIDEO) {
for(i=0;i<6;i++) {
if (cbp & 32) {
if (mpeg2_decode_block_non_intra(s, block[i], i) < 0)
@@ -1204,23 +1325,23 @@ static int mpeg_decode_motion(MpegEncContext *s, int fcode, int pred)
return val;
}
-static inline int decode_dc(MpegEncContext *s, int component)
+static inline int decode_dc(GetBitContext *gb, int component)
{
int code, diff;
if (component == 0) {
- code = get_vlc2(&s->gb, dc_lum_vlc.table, DC_VLC_BITS, 2);
+ code = get_vlc2(gb, dc_lum_vlc.table, DC_VLC_BITS, 2);
} else {
- code = get_vlc2(&s->gb, dc_chroma_vlc.table, DC_VLC_BITS, 2);
+ code = get_vlc2(gb, dc_chroma_vlc.table, DC_VLC_BITS, 2);
}
if (code < 0){
- fprintf(stderr, "invalid dc code at %d %d\n", s->mb_x, s->mb_y);
+ fprintf(stderr, "invalid dc code at\n");
return 0xffff;
}
if (code == 0) {
diff = 0;
} else {
- diff = get_xbits(&s->gb, code);
+ diff = get_xbits(gb, code);
}
return diff;
}
@@ -1238,7 +1359,7 @@ static inline int mpeg1_decode_block_intra(MpegEncContext *s,
/* DC coef */
component = (n <= 3 ? 0 : n - 4 + 1);
- diff = decode_dc(s, component);
+ diff = decode_dc(&s->gb, component);
if (diff >= 0xffff)
return -1;
dc = s->last_dc[component];
@@ -1475,7 +1596,7 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s,
quant_matrix = s->chroma_intra_matrix;
component = n - 3;
}
- diff = decode_dc(s, component);
+ diff = decode_dc(&s->gb, component);
if (diff >= 0xffff)
return -1;
dc = s->last_dc[component];
@@ -1539,6 +1660,7 @@ typedef struct Mpeg1Context {
MpegEncContext mpeg_enc_ctx;
int mpeg_enc_ctx_allocated; /* true if decoding context allocated */
int repeat_field; /* true if we must repeat the field */
+ AVPanScan pan_scan; /** some temporary storage for the panscan */
} Mpeg1Context;
static int mpeg_decode_init(AVCodecContext *avctx)
@@ -1547,7 +1669,7 @@ static int mpeg_decode_init(AVCodecContext *avctx)
s->mpeg_enc_ctx.flags= avctx->flags;
common_init(&s->mpeg_enc_ctx);
- init_vlcs(&s->mpeg_enc_ctx);
+ init_vlcs();
s->mpeg_enc_ctx_allocated = 0;
s->mpeg_enc_ctx.picture_number = 0;
@@ -1624,9 +1746,11 @@ static void mpeg_decode_sequence_extension(MpegEncContext *s)
int horiz_size_ext, vert_size_ext;
int bit_rate_ext, vbv_buf_ext;
int frame_rate_ext_n, frame_rate_ext_d;
- float aspect;
+ int level, profile;
- skip_bits(&s->gb, 8); /* profil and level */
+ skip_bits(&s->gb, 1); /* profil and level esc*/
+ profile= get_bits(&s->gb, 3);
+ level= get_bits(&s->gb, 4);
s->progressive_sequence = get_bits1(&s->gb); /* progressive_sequence */
skip_bits(&s->gb, 2); /* chroma_format */
horiz_size_ext = get_bits(&s->gb, 2);
@@ -1637,7 +1761,10 @@ static void mpeg_decode_sequence_extension(MpegEncContext *s)
s->bit_rate = ((s->bit_rate / 400) | (bit_rate_ext << 12)) * 400;
skip_bits1(&s->gb); /* marker */
vbv_buf_ext = get_bits(&s->gb, 8);
+
s->low_delay = get_bits1(&s->gb);
+ if(s->flags & CODEC_FLAG_LOW_DELAY) s->low_delay=1;
+
frame_rate_ext_n = get_bits(&s->gb, 2);
frame_rate_ext_d = get_bits(&s->gb, 5);
av_reduce(
@@ -1648,12 +1775,72 @@ static void mpeg_decode_sequence_extension(MpegEncContext *s)
1<<30);
dprintf("sequence extension\n");
- s->mpeg2 = 1;
+ s->codec_id= s->avctx->codec_id= CODEC_ID_MPEG2VIDEO;
s->avctx->sub_id = 2; /* indicates mpeg2 found */
- aspect= mpeg2_aspect[s->aspect_ratio_info];
- if(aspect>0.0) s->avctx->aspect_ratio= s->width/(aspect*s->height);
- else if(aspect<0.0) s->avctx->aspect_ratio= -1.0/aspect;
+ if(s->aspect_ratio_info <= 1)
+ s->avctx->sample_aspect_ratio= mpeg2_aspect[s->aspect_ratio_info];
+ else{
+ s->avctx->sample_aspect_ratio=
+ av_div_q(
+ mpeg2_aspect[s->aspect_ratio_info],
+ (AVRational){s->width, s->height}
+ );
+ }
+
+ if(s->avctx->debug & FF_DEBUG_PICT_INFO)
+ printf("profile: %d, level: %d \n", profile, level);
+}
+
+static void mpeg_decode_sequence_display_extension(Mpeg1Context *s1)
+{
+ MpegEncContext *s= &s1->mpeg_enc_ctx;
+ int color_description, w, h;
+
+ skip_bits(&s->gb, 3); /* video format */
+ color_description= get_bits1(&s->gb);
+ if(color_description){
+ skip_bits(&s->gb, 8); /* color primaries */
+ skip_bits(&s->gb, 8); /* transfer_characteristics */
+ skip_bits(&s->gb, 8); /* matrix_coefficients */
+ }
+ w= get_bits(&s->gb, 14);
+ skip_bits(&s->gb, 1); //marker
+ h= get_bits(&s->gb, 14);
+ skip_bits(&s->gb, 1); //marker
+
+ s1->pan_scan.width= 16*w;
+ s1->pan_scan.height=16*h;
+
+ if(s->aspect_ratio_info > 1)
+ s->avctx->sample_aspect_ratio=
+ av_div_q(
+ mpeg2_aspect[s->aspect_ratio_info],
+ (AVRational){w, h}
+ );
+
+ if(s->avctx->debug & FF_DEBUG_PICT_INFO)
+ printf("sde w:%d, h:%d\n", w, h);
+}
+
+static void mpeg_decode_picture_display_extension(Mpeg1Context *s1)
+{
+ MpegEncContext *s= &s1->mpeg_enc_ctx;
+ int i;
+
+ for(i=0; i<1; i++){ //FIXME count
+ s1->pan_scan.position[i][0]= get_sbits(&s->gb, 16);
+ skip_bits(&s->gb, 1); //marker
+ s1->pan_scan.position[i][1]= get_sbits(&s->gb, 16);
+ skip_bits(&s->gb, 1); //marker
+ }
+
+ if(s->avctx->debug & FF_DEBUG_PICT_INFO)
+ printf("pde (%d,%d) (%d,%d) (%d,%d)\n",
+ s1->pan_scan.position[0][0], s1->pan_scan.position[0][1],
+ s1->pan_scan.position[1][0], s1->pan_scan.position[1][1],
+ s1->pan_scan.position[2][0], s1->pan_scan.position[2][1]
+ );
}
static void mpeg_decode_quant_matrix_extension(MpegEncContext *s)
@@ -1756,20 +1943,29 @@ static void mpeg_decode_extension(AVCodecContext *avctx,
ext_type = get_bits(&s->gb, 4);
switch(ext_type) {
case 0x1:
- /* sequence ext */
mpeg_decode_sequence_extension(s);
break;
+ case 0x2:
+ mpeg_decode_sequence_display_extension(s1);
+ break;
case 0x3:
- /* quant matrix extension */
mpeg_decode_quant_matrix_extension(s);
break;
+ case 0x7:
+ mpeg_decode_picture_display_extension(s1);
+ break;
case 0x8:
- /* picture extension */
mpeg_decode_picture_coding_extension(s);
break;
}
}
+static void exchange_uv(AVFrame *f){
+ uint8_t *t= f->data[1];
+ f->data[1]= f->data[2];
+ f->data[2]= t;
+}
+
#define DECODE_SLICE_FATAL_ERROR -2
#define DECODE_SLICE_ERROR -1
#define DECODE_SLICE_OK 0
@@ -1811,19 +2007,21 @@ static int mpeg_decode_slice(AVCodecContext *avctx,
ff_er_frame_start(s);
/* first check if we must repeat the frame */
- s->current_picture.repeat_pict = 0;
-
+ s->current_picture_ptr->repeat_pict = 0;
if (s->repeat_first_field) {
if (s->progressive_sequence) {
if (s->top_field_first)
- s->current_picture.repeat_pict = 4;
+ s->current_picture_ptr->repeat_pict = 4;
else
- s->current_picture.repeat_pict = 2;
+ s->current_picture_ptr->repeat_pict = 2;
} else if (s->progressive_frame) {
- s->current_picture.repeat_pict = 1;
+ s->current_picture_ptr->repeat_pict = 1;
}
}
-// printf("%d \n", s->current_picture.repeat_pict);
+
+ *s->current_picture_ptr->pan_scan= s1->pan_scan;
+
+ //printf("%d\n", s->current_picture_ptr->repeat_pict);
if(s->avctx->debug&FF_DEBUG_PICT_INFO){
printf("qp:%d fc:%2d%2d%2d%2d %s %s %s %s dc:%d pstruct:%d fdct:%d cmv:%d qtype:%d ivlc:%d rff:%d %s\n",
@@ -1848,7 +2046,13 @@ static int mpeg_decode_slice(AVCodecContext *avctx,
}
}
}
- }
+#ifdef HAVE_XVMC
+// MPV_frame_start will call this function too,
+// but we need to call it on every field
+ if(s->avctx->xvmc_acceleration)
+ XVMC_field_start(s,avctx);
+#endif
+ }//fi(s->first_slice)
s->first_slice = 0;
init_get_bits(&s->gb, *buf, buf_size*8);
@@ -1886,6 +2090,7 @@ static int mpeg_decode_slice(AVCodecContext *avctx,
s->resync_mb_x= s->mb_x;
s->resync_mb_y= s->mb_y = start_code;
s->mb_skip_run= 0;
+ ff_init_block_index(s);
for(;;) {
s->dsp.clear_blocks(s->block[0]);
@@ -1921,16 +2126,20 @@ static int mpeg_decode_slice(AVCodecContext *avctx,
s->motion_val[xy + 1 + wrap][1] = motion_y;
}
- MPV_decode_mb(s, s->block);
+ s->dest[0] += 16;
+ s->dest[1] += 8;
+ s->dest[2] += 8;
+ MPV_decode_mb(s, s->block);
+
if (++s->mb_x >= s->mb_width) {
- if(s->picture_structure==PICT_FRAME){
- ff_draw_horiz_band(s, 16*s->mb_y, 16);
- }else{
- if(!s->first_field){
- ff_draw_horiz_band(s, 32*s->mb_y, 32);
- }
- }
+ if(s->avctx->codec_tag == ff_get_fourcc("VCR2"))
+ exchange_uv((AVFrame*)s->current_picture_ptr);
+
+ ff_draw_horiz_band(s, 16*s->mb_y, 16);
+
+ if(s->avctx->codec_tag == ff_get_fourcc("VCR2"))
+ exchange_uv((AVFrame*)s->current_picture_ptr);
s->mb_x = 0;
s->mb_y++;
@@ -1945,6 +2154,8 @@ static int mpeg_decode_slice(AVCodecContext *avctx,
}else
goto eos;
}
+
+ ff_init_block_index(s);
}
/* skip mb handling */
@@ -1990,14 +2201,18 @@ static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Mpeg1Context *s1 = avctx->priv_data;
MpegEncContext *s = &s1->mpeg_enc_ctx;
- if (!s1->mpeg_enc_ctx_allocated)
+ if (!s1->mpeg_enc_ctx_allocated || !s->current_picture_ptr)
return 0;
+#ifdef HAVE_XVMC
+ if(s->avctx->xvmc_acceleration)
+ XVMC_field_end(s);
+#endif
/* end of slice reached */
if (/*s->mb_y<<field_pic == s->mb_height &&*/ !s->first_field) {
/* end of image */
- if(s->mpeg2){
+ if(s->codec_id == CODEC_ID_MPEG2VIDEO){
s->current_picture_ptr->qscale_type= FF_QSCALE_TYPE_MPEG2;
}else
s->current_picture_ptr->qscale_type= FF_QSCALE_TYPE_MPEG1;
@@ -2007,17 +2222,20 @@ static int slice_end(AVCodecContext *avctx, AVFrame *pict)
MPV_frame_end(s);
if (s->pict_type == B_TYPE || s->low_delay) {
- *pict= *(AVFrame*)&s->current_picture;
+ *pict= *(AVFrame*)s->current_picture_ptr;
ff_print_debug_info(s, s->current_picture_ptr);
} else {
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) {
- *pict= *(AVFrame*)&s->last_picture;
+ *pict= *(AVFrame*)s->last_picture_ptr;
ff_print_debug_info(s, s->last_picture_ptr);
}
}
+ if(s->avctx->codec_tag == ff_get_fourcc("VCR2"))
+ exchange_uv(pict);
+
return 1;
} else {
return 0;
@@ -2037,9 +2255,9 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx,
width = get_bits(&s->gb, 12);
height = get_bits(&s->gb, 12);
s->aspect_ratio_info= get_bits(&s->gb, 4);
- if(!s->mpeg2){
+ if(s->codec_id == CODEC_ID_MPEG1VIDEO){
aspect= mpeg1_aspect[s->aspect_ratio_info];
- if(aspect!=0.0) avctx->aspect_ratio= width/(aspect*height);
+ if(aspect!=0.0) avctx->sample_aspect_ratio= av_d2q(aspect, 255);
}
s->frame_rate_index = get_bits(&s->gb, 4);
@@ -2073,6 +2291,11 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx,
);
avctx->bit_rate = s->bit_rate;
+ //get_format() or set_video(width,height,aspect,pix_fmt);
+ //until then pix_fmt may be changed right after codec init
+ if( avctx->pix_fmt == PIX_FMT_XVMC_MPEG2_IDCT )
+ avctx->idct_algo = FF_IDCT_SIMPLE;
+
if (MPV_common_init(s) < 0)
return -1;
s1->mpeg_enc_ctx_allocated = 1;
@@ -2130,11 +2353,58 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx,
s->progressive_frame = 1;
s->picture_structure = PICT_FRAME;
s->frame_pred_frame_dct = 1;
- s->mpeg2 = 0;
+ s->codec_id= s->avctx->codec_id= CODEC_ID_MPEG1VIDEO;
avctx->sub_id = 1; /* indicates mpeg1 */
return 0;
}
+static int vcr2_init_sequence(AVCodecContext *avctx)
+{
+ Mpeg1Context *s1 = avctx->priv_data;
+ MpegEncContext *s = &s1->mpeg_enc_ctx;
+ int i, v;
+
+ /* start new mpeg1 context decoding */
+ s->out_format = FMT_MPEG1;
+ if (s1->mpeg_enc_ctx_allocated) {
+ MPV_common_end(s);
+ }
+ s->width = avctx->width;
+ s->height = avctx->height;
+ avctx->has_b_frames= 0; //true?
+ s->low_delay= 1;
+ s->avctx = avctx;
+
+ //get_format() or set_video(width,height,aspect,pix_fmt);
+ //until then pix_fmt may be changed right after codec init
+ if( avctx->pix_fmt == PIX_FMT_XVMC_MPEG2_IDCT )
+ avctx->idct_algo = FF_IDCT_SIMPLE;
+
+ if (MPV_common_init(s) < 0)
+ return -1;
+ s1->mpeg_enc_ctx_allocated = 1;
+
+ for(i=0;i<64;i++) {
+ int j= s->dsp.idct_permutation[i];
+ v = ff_mpeg1_default_intra_matrix[i];
+ s->intra_matrix[j] = v;
+ s->chroma_intra_matrix[j] = v;
+
+ v = ff_mpeg1_default_non_intra_matrix[i];
+ s->inter_matrix[j] = v;
+ s->chroma_inter_matrix[j] = v;
+ }
+
+ s->progressive_sequence = 1;
+ s->progressive_frame = 1;
+ s->picture_structure = PICT_FRAME;
+ s->frame_pred_frame_dct = 1;
+ s->codec_id= s->avctx->codec_id= CODEC_ID_MPEG2VIDEO;
+ avctx->sub_id = 2; /* indicates mpeg2 */
+ return 0;
+}
+
+
static void mpeg_decode_user_data(AVCodecContext *avctx,
const uint8_t *buf, int buf_size)
{
@@ -2218,12 +2488,11 @@ static int mpeg_decode_frame(AVCodecContext *avctx,
*data_size = 0;
/* special case for last picture */
- if (buf_size == 0) {
- if (s2->picture_number > 0) {
- *picture= *(AVFrame*)&s2->next_picture;
+ if (buf_size == 0 && s2->low_delay==0 && s2->next_picture_ptr) {
+ *picture= *(AVFrame*)s2->next_picture_ptr;
+ s2->next_picture_ptr= NULL;
- *data_size = sizeof(AVFrame);
- }
+ *data_size = sizeof(AVFrame);
return 0;
}
@@ -2248,13 +2517,19 @@ static int mpeg_decode_frame(AVCodecContext *avctx,
}
}
#endif
+
+ if(s->mpeg_enc_ctx_allocated==0 && avctx->codec_tag == ff_get_fourcc("VCR2"))
+ vcr2_init_sequence(avctx);
+
for(;;) {
/* find start next code */
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(s2->pict_type != B_TYPE || avctx->hurry_up==0){
+ if (slice_end(avctx, picture)) {
+ if(s2->last_picture_ptr) //FIXME merge with the stuff in mpeg_decode_slice
+ *data_size = sizeof(AVPicture);
+ }
}
return FFMAX(0, buf_ptr - buf - s2->parse_context.last_index);
}
@@ -2285,6 +2560,9 @@ static int mpeg_decode_frame(AVCodecContext *avctx,
mpeg_decode_user_data(avctx,
buf_ptr, input_size);
break;
+ case GOP_START_CODE:
+ s2->first_field=0;
+ break;
default:
if (start_code >= SLICE_MIN_START_CODE &&
start_code <= SLICE_MAX_START_CODE) {
@@ -2324,8 +2602,8 @@ static int mpeg_decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec mpeg_decoder = {
- "mpegvideo",
+AVCodec mpeg1video_decoder = {
+ "mpeg1video",
CODEC_TYPE_VIDEO,
CODEC_ID_MPEG1VIDEO,
sizeof(Mpeg1Context),
@@ -2334,4 +2612,55 @@ AVCodec mpeg_decoder = {
mpeg_decode_end,
mpeg_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED,
+ .flush= ff_mpeg_flush,
+};
+
+AVCodec mpeg2video_decoder = {
+ "mpeg2video",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_MPEG2VIDEO,
+ sizeof(Mpeg1Context),
+ mpeg_decode_init,
+ NULL,
+ mpeg_decode_end,
+ mpeg_decode_frame,
+ CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED,
+ .flush= ff_mpeg_flush,
};
+
+#ifdef HAVE_XVMC
+static int mpeg_mc_decode_init(AVCodecContext *avctx){
+ Mpeg1Context *s;
+
+ if( !(avctx->slice_flags & SLICE_FLAG_CODED_ORDER) )
+ return -1;
+ if( !(avctx->slice_flags & SLICE_FLAG_ALLOW_FIELD) )
+ dprintf("mpeg12.c: XvMC decoder will work better if SLICE_FLAG_ALLOW_FIELD is set\n");
+
+ mpeg_decode_init(avctx);
+ s = avctx->priv_data;
+
+ avctx->pix_fmt = PIX_FMT_XVMC_MPEG2_IDCT;
+ avctx->xvmc_acceleration = 1;
+
+ return 0;
+}
+
+AVCodec mpeg_xvmc_decoder = {
+ "mpegvideo_xvmc",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_MPEG2VIDEO_XVMC,
+ sizeof(Mpeg1Context),
+ mpeg_mc_decode_init,
+ NULL,
+ mpeg_decode_end,
+ mpeg_decode_frame,
+ CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED,
+};
+
+#endif
+
+/* this is ugly i know, but the alternative is too make
+ hundreds of vars global and prefix them with ff_mpeg1_
+ which is far uglier. */
+#include "mdec.c"
diff --git a/src/libffmpeg/libavcodec/mpeg12data.h b/src/libffmpeg/libavcodec/mpeg12data.h
index ba52ef22e..dd94bb572 100644
--- a/src/libffmpeg/libavcodec/mpeg12data.h
+++ b/src/libffmpeg/libavcodec/mpeg12data.h
@@ -25,7 +25,7 @@ const int16_t ff_mpeg1_default_non_intra_matrix[64] = {
16, 16, 16, 16, 16, 16, 16, 16,
};
-const unsigned char vlc_dc_table[256] = {
+static const unsigned char vlc_dc_table[256] = {
0, 1, 2, 2,
3, 3, 3, 3,
4, 4, 4, 4, 4, 4, 4, 4,
@@ -48,10 +48,10 @@ const unsigned char vlc_dc_table[256] = {
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
};
-const uint16_t vlc_dc_lum_code[12] = {
+static const uint16_t vlc_dc_lum_code[12] = {
0x4, 0x0, 0x1, 0x5, 0x6, 0xe, 0x1e, 0x3e, 0x7e, 0xfe, 0x1fe, 0x1ff,
};
-const unsigned char vlc_dc_lum_bits[12] = {
+static const unsigned char vlc_dc_lum_bits[12] = {
3, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 9,
};
@@ -62,10 +62,6 @@ const unsigned char vlc_dc_chroma_bits[12] = {
2, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10,
};
-/* simple include everything table for dc, first byte is bits number next 3 are code*/
-static uint32_t mpeg1_lum_dc_uni[512];
-static uint32_t mpeg1_chr_dc_uni[512];
-
static const uint16_t mpeg1_vlc[113][2] = {
{ 0x3, 2 }, { 0x4, 4 }, { 0x5, 5 }, { 0x6, 7 },
{ 0x26, 8 }, { 0x21, 8 }, { 0xa, 10 }, { 0x1d, 12 },
@@ -166,9 +162,6 @@ static const int8_t mpeg1_run[111] = {
25, 26, 27, 28, 29, 30, 31,
};
-static uint8_t mpeg1_index_run[2][64];
-static int8_t mpeg1_max_level[2][64];
-
static RLTable rl_mpeg1 = {
111,
111,
@@ -423,11 +416,22 @@ static const float mpeg1_aspect[16]={
1.2015,
};
-static const float mpeg2_aspect[16]={
- 0,
- 1.0,
- -3.0/4.0,
- -9.0/16.0,
- -1.0/2.21,
+static const AVRational mpeg2_aspect[16]={
+ {0,1},
+ {1,1},
+ {4,3},
+ {16,9},
+ {221,100},
+ {0,1},
+ {0,1},
+ {0,1},
+ {0,1},
+ {0,1},
+ {0,1},
+ {0,1},
+ {0,1},
+ {0,1},
+ {0,1},
+ {0,1},
};
diff --git a/src/libffmpeg/libavcodec/mpeg4data.h b/src/libffmpeg/libavcodec/mpeg4data.h
index bc0d4530e..0092a9f5e 100644
--- a/src/libffmpeg/libavcodec/mpeg4data.h
+++ b/src/libffmpeg/libavcodec/mpeg4data.h
@@ -27,7 +27,7 @@
#define MOTION_MARKER 0x1F001
#define DC_MARKER 0x6B001
-const static int mb_type_b_map[4]= {
+static const int mb_type_b_map[4]= {
MB_TYPE_DIRECT2 | MB_TYPE_L0L1,
MB_TYPE_L0L1 | MB_TYPE_16x16,
MB_TYPE_L1 | MB_TYPE_16x16,
@@ -341,23 +341,23 @@ static const uint8_t mb_type_b_tab[4][2] = {
{1, 1}, {1, 2}, {1, 3}, {1, 4},
};
-static const uint16_t pixel_aspect[16][2]={
- {0, 0},
+static const AVRational pixel_aspect[16]={
+ {0, 1},
{1, 1},
{12, 11},
{10, 11},
{16, 11},
{40, 33},
- {0, 0},
- {0, 0},
- {0, 0},
- {0, 0},
- {0, 0},
- {0, 0},
- {0, 0},
- {0, 0},
- {0, 0},
- {0, 0},
+ {0, 1},
+ {0, 1},
+ {0, 1},
+ {0, 1},
+ {0, 1},
+ {0, 1},
+ {0, 1},
+ {0, 1},
+ {0, 1},
+ {0, 1},
};
/* these matrixes will be permuted for the idct */
@@ -395,3 +395,7 @@ uint8_t ff_mpeg4_c_dc_scale_table[32]={
const uint16_t ff_mpeg4_resync_prefix[8]={
0x7F00, 0x7E00, 0x7C00, 0x7800, 0x7000, 0x6000, 0x4000, 0x0000
};
+
+static const uint8_t mpeg4_dc_threshold[8]={
+ 99, 13, 15, 17, 19, 21, 23, 0
+};
diff --git a/src/libffmpeg/libavcodec/mpegaudiodec.c b/src/libffmpeg/libavcodec/mpegaudiodec.c
index 1d1074aa7..51c8ef130 100644
--- a/src/libffmpeg/libavcodec/mpegaudiodec.c
+++ b/src/libffmpeg/libavcodec/mpegaudiodec.c
@@ -310,7 +310,7 @@ static int decode_init(AVCodecContext * avctx)
static int init=0;
int i, j, k;
- if(!init) {
+ if (!init && !avctx->parse_only) {
/* scale factors table for layer 1/2 */
for(i=0;i<64;i++) {
int shift, mod;
@@ -737,57 +737,95 @@ static void dct32(int32_t *out, int32_t *tab)
#if FRAC_BITS <= 15
-#define OUT_SAMPLE(sum)\
-{\
- int sum1;\
- sum1 = (sum + (1 << (OUT_SHIFT - 1))) >> OUT_SHIFT;\
- if (sum1 < -32768)\
- sum1 = -32768;\
- else if (sum1 > 32767)\
- sum1 = 32767;\
- *samples = sum1;\
- samples += incr;\
+static inline int round_sample(int sum)
+{
+ int sum1;
+ sum1 = (sum + (1 << (OUT_SHIFT - 1))) >> OUT_SHIFT;
+ if (sum1 < -32768)
+ sum1 = -32768;
+ else if (sum1 > 32767)
+ sum1 = 32767;
+ return sum1;
}
-#define SUM8(off, op) \
-{ \
- sum op w[0 * 64 + off] * p[0 * 64];\
- sum op w[1 * 64 + off] * p[1 * 64];\
- sum op w[2 * 64 + off] * p[2 * 64];\
- sum op w[3 * 64 + off] * p[3 * 64];\
- sum op w[4 * 64 + off] * p[4 * 64];\
- sum op w[5 * 64 + off] * p[5 * 64];\
- sum op w[6 * 64 + off] * p[6 * 64];\
- sum op w[7 * 64 + off] * p[7 * 64];\
-}
+#if defined(ARCH_POWERPC_405)
+
+/* signed 16x16 -> 32 multiply add accumulate */
+#define MACS(rt, ra, rb) \
+ asm ("maclhw %0, %2, %3" : "=r" (rt) : "0" (rt), "r" (ra), "r" (rb));
+
+/* signed 16x16 -> 32 multiply */
+#define MULS(ra, rb) \
+ ({ int __rt; asm ("mullhw %0, %1, %2" : "=r" (__rt) : "r" (ra), "r" (rb)); __rt; })
#else
-#define OUT_SAMPLE(sum)\
-{\
- int sum1;\
- sum1 = (int)((sum + (int64_t_C(1) << (OUT_SHIFT - 1))) >> OUT_SHIFT);\
- if (sum1 < -32768)\
- sum1 = -32768;\
- else if (sum1 > 32767)\
- sum1 = 32767;\
- *samples = sum1;\
- samples += incr;\
+/* signed 16x16 -> 32 multiply add accumulate */
+#define MACS(rt, ra, rb) rt += (ra) * (rb)
+
+/* signed 16x16 -> 32 multiply */
+#define MULS(ra, rb) ((ra) * (rb))
+
+#endif
+
+#else
+
+static inline int round_sample(int64_t sum)
+{
+ int sum1;
+ sum1 = (int)((sum + (int64_t_C(1) << (OUT_SHIFT - 1))) >> OUT_SHIFT);
+ if (sum1 < -32768)
+ sum1 = -32768;
+ else if (sum1 > 32767)
+ sum1 = 32767;
+ return sum1;
}
-#define SUM8(off, op) \
+#define MULS(ra, rb) MUL64(ra, rb)
+
+#endif
+
+#define SUM8(sum, op, w, p) \
{ \
- sum op MUL64(w[0 * 64 + off], p[0 * 64]);\
- sum op MUL64(w[1 * 64 + off], p[1 * 64]);\
- sum op MUL64(w[2 * 64 + off], p[2 * 64]);\
- sum op MUL64(w[3 * 64 + off], p[3 * 64]);\
- sum op MUL64(w[4 * 64 + off], p[4 * 64]);\
- sum op MUL64(w[5 * 64 + off], p[5 * 64]);\
- sum op MUL64(w[6 * 64 + off], p[6 * 64]);\
- sum op MUL64(w[7 * 64 + off], p[7 * 64]);\
+ sum op MULS((w)[0 * 64], p[0 * 64]);\
+ sum op MULS((w)[1 * 64], p[1 * 64]);\
+ sum op MULS((w)[2 * 64], p[2 * 64]);\
+ sum op MULS((w)[3 * 64], p[3 * 64]);\
+ sum op MULS((w)[4 * 64], p[4 * 64]);\
+ sum op MULS((w)[5 * 64], p[5 * 64]);\
+ sum op MULS((w)[6 * 64], p[6 * 64]);\
+ sum op MULS((w)[7 * 64], p[7 * 64]);\
+}
+
+#define SUM8P2(sum1, op1, sum2, op2, w1, w2, p) \
+{ \
+ int tmp;\
+ tmp = p[0 * 64];\
+ sum1 op1 MULS((w1)[0 * 64], tmp);\
+ sum2 op2 MULS((w2)[0 * 64], tmp);\
+ tmp = p[1 * 64];\
+ sum1 op1 MULS((w1)[1 * 64], tmp);\
+ sum2 op2 MULS((w2)[1 * 64], tmp);\
+ tmp = p[2 * 64];\
+ sum1 op1 MULS((w1)[2 * 64], tmp);\
+ sum2 op2 MULS((w2)[2 * 64], tmp);\
+ tmp = p[3 * 64];\
+ sum1 op1 MULS((w1)[3 * 64], tmp);\
+ sum2 op2 MULS((w2)[3 * 64], tmp);\
+ tmp = p[4 * 64];\
+ sum1 op1 MULS((w1)[4 * 64], tmp);\
+ sum2 op2 MULS((w2)[4 * 64], tmp);\
+ tmp = p[5 * 64];\
+ sum1 op1 MULS((w1)[5 * 64], tmp);\
+ sum2 op2 MULS((w2)[5 * 64], tmp);\
+ tmp = p[6 * 64];\
+ sum1 op1 MULS((w1)[6 * 64], tmp);\
+ sum2 op2 MULS((w2)[6 * 64], tmp);\
+ tmp = p[7 * 64];\
+ sum1 op1 MULS((w1)[7 * 64], tmp);\
+ sum2 op2 MULS((w2)[7 * 64], tmp);\
}
-#endif
/* 32 sub band synthesis filter. Input: 32 sub band samples, Output:
32 samples. */
@@ -797,15 +835,16 @@ static void synth_filter(MPADecodeContext *s1,
int32_t sb_samples[SBLIMIT])
{
int32_t tmp[32];
- register MPA_INT *synth_buf, *p;
- register MPA_INT *w;
+ register MPA_INT *synth_buf;
+ const register MPA_INT *w, *w2, *p;
int j, offset, v;
+ int16_t *samples2;
#if FRAC_BITS <= 15
- int sum;
+ int sum, sum2;
#else
- int64_t sum;
+ int64_t sum, sum2;
#endif
-
+
dct32(tmp, sb_samples);
offset = s1->synth_buf_offset[ch];
@@ -826,32 +865,42 @@ static void synth_filter(MPADecodeContext *s1,
/* copy to avoid wrap */
memcpy(synth_buf + 512, synth_buf, 32 * sizeof(MPA_INT));
+ samples2 = samples + 31 * incr;
w = window;
- for(j=0;j<16;j++) {
- sum = 0;
- p = synth_buf + 16 + j; /* 0-15 */
- SUM8(0, +=);
- p = synth_buf + 48 - j; /* 32-47 */
- SUM8(32, -=);
- OUT_SAMPLE(sum);
- w++;
- }
-
- p = synth_buf + 32; /* 48 */
+ w2 = window + 31;
+
sum = 0;
- SUM8(32, -=);
- OUT_SAMPLE(sum);
+ p = synth_buf + 16;
+ SUM8(sum, +=, w, p);
+ p = synth_buf + 48;
+ SUM8(sum, -=, w + 32, p);
+ *samples = round_sample(sum);
+ samples += incr;
w++;
- for(j=17;j<32;j++) {
+ /* we calculate two samples at the same time to avoid one memory
+ access per two sample */
+ for(j=1;j<16;j++) {
sum = 0;
- p = synth_buf + 48 - j; /* 17-31 */
- SUM8(0, -=);
- p = synth_buf + 16 + j; /* 49-63 */
- SUM8(32, -=);
- OUT_SAMPLE(sum);
+ sum2 = 0;
+ p = synth_buf + 16 + j;
+ SUM8P2(sum, +=, sum2, -=, w, w2, p);
+ p = synth_buf + 48 - j;
+ SUM8P2(sum, -=, sum2, -=, w + 32, w2 + 32, p);
+
+ *samples = round_sample(sum);
+ samples += incr;
+ *samples2 = round_sample(sum2);
+ samples2 -= incr;
w++;
+ w2--;
}
+
+ p = synth_buf + 32;
+ sum = 0;
+ SUM8(sum, -=, w + 32, p);
+ *samples = round_sample(sum);
+
offset = (offset - 32) & 511;
s1->synth_buf_offset[ch] = offset;
}
@@ -1157,6 +1206,47 @@ static int decode_header(MPADecodeContext *s, uint32_t header)
return 0;
}
+/* useful helper to get mpeg audio stream infos. Return -1 if error in
+ header */
+int mp_decode_header(int *sample_rate_ptr,
+ int *nb_channels_ptr,
+ int *coded_frame_size_ptr,
+ int *decoded_frame_size_ptr,
+ uint32_t head)
+{
+ MPADecodeContext s1, *s = &s1;
+ int decoded_frame_size;
+
+ if (check_header(head) != 0)
+ return -1;
+
+ if (decode_header(s, head) != 0) {
+ return -1;
+ }
+
+ switch(s->layer) {
+ case 1:
+ decoded_frame_size = 384;
+ break;
+ case 2:
+ decoded_frame_size = 1152;
+ break;
+ default:
+ case 3:
+ if (s->lsf)
+ decoded_frame_size = 576;
+ else
+ decoded_frame_size = 1152;
+ break;
+ }
+
+ *sample_rate_ptr = s->sample_rate;
+ *nb_channels_ptr = s->nb_channels;
+ *coded_frame_size_ptr = s->frame_size;
+ *decoded_frame_size_ptr = decoded_frame_size * 2 * s->nb_channels;
+ return 0;
+}
+
/* return the number of decoded frames */
static int mp_decode_layer1(MPADecodeContext *s)
{
@@ -1460,7 +1550,7 @@ static void seek_to_maindata(MPADecodeContext *s, unsigned int backstep)
uint8_t *ptr;
/* compute current position in stream */
- ptr = s->gb.buffer + (get_bits_count(&s->gb)>>3);
+ ptr = (uint8_t *)(s->gb.buffer + (get_bits_count(&s->gb)>>3));
/* copy old data before current one */
ptr -= backstep;
@@ -2376,7 +2466,7 @@ static int decode_frame(AVCodecContext * avctx,
if (check_header(header) < 0) {
/* no sync found : move by one byte (inefficient, but simple!) */
- memcpy(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1);
+ memmove(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1);
s->inbuf_ptr--;
dprintf("skip %x\n", header);
/* reset free format frame size to give a chance
@@ -2391,7 +2481,21 @@ static int decode_frame(AVCodecContext * avctx,
avctx->sample_rate = s->sample_rate;
avctx->channels = s->nb_channels;
avctx->bit_rate = s->bit_rate;
- avctx->frame_size = s->frame_size;
+ avctx->sub_id = s->layer;
+ switch(s->layer) {
+ case 1:
+ avctx->frame_size = 384;
+ break;
+ case 2:
+ avctx->frame_size = 1152;
+ break;
+ case 3:
+ if (s->lsf)
+ avctx->frame_size = 576;
+ else
+ avctx->frame_size = 1152;
+ break;
+ }
}
}
} else if (s->frame_size == -1) {
@@ -2402,7 +2506,7 @@ static int decode_frame(AVCodecContext * avctx,
if (len == 0) {
/* frame too long: resync */
s->frame_size = 0;
- memcpy(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1);
+ memmove(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1);
s->inbuf_ptr--;
} else {
uint8_t *p, *pend;
@@ -2457,15 +2561,22 @@ static int decode_frame(AVCodecContext * avctx,
buf_ptr += len;
s->inbuf_ptr += len;
buf_size -= len;
- } else {
- out_size = mp_decode_frame(s, out_samples);
+ }
+ next_data:
+ if (s->frame_size > 0 &&
+ (s->inbuf_ptr - s->inbuf) >= s->frame_size) {
+ if (avctx->parse_only) {
+ /* simply return the frame data */
+ *(uint8_t **)data = s->inbuf;
+ out_size = s->inbuf_ptr - s->inbuf;
+ } else {
+ out_size = mp_decode_frame(s, out_samples);
+ }
s->inbuf_ptr = s->inbuf;
s->frame_size = 0;
*data_size = out_size;
break;
}
- next_data:
- ;
}
return buf_ptr - buf;
}
@@ -2480,27 +2591,18 @@ AVCodec mp2_decoder =
NULL,
NULL,
decode_frame,
+ CODEC_CAP_PARSE_ONLY,
};
AVCodec mp3_decoder =
{
"mp3",
CODEC_TYPE_AUDIO,
- CODEC_ID_MP3LAME,
+ CODEC_ID_MP3,
sizeof(MPADecodeContext),
decode_init,
NULL,
NULL,
decode_frame,
+ CODEC_CAP_PARSE_ONLY,
};
-
-#undef C1
-#undef C2
-#undef C3
-#undef C4
-#undef C5
-#undef C6
-#undef C7
-#undef C8
-#undef FRAC_BITS
-#undef HEADER_SIZE
diff --git a/src/libffmpeg/libavcodec/mpegvideo.c b/src/libffmpeg/libavcodec/mpegvideo.c
index 83a481e9f..0e04301a4 100644
--- a/src/libffmpeg/libavcodec/mpegvideo.c
+++ b/src/libffmpeg/libavcodec/mpegvideo.c
@@ -24,7 +24,6 @@
* The simplest mpeg encoder (well, it was the simplest!).
*/
-#include <ctype.h>
#include <limits.h>
#include "avcodec.h"
#include "dsputil.h"
@@ -50,8 +49,15 @@ static void draw_edges_c(uint8_t *buf, int wrap, int width, int height, int w);
#ifdef CONFIG_ENCODERS
static int dct_quantize_c(MpegEncContext *s, DCTELEM *block, int n, int qscale, int *overflow);
static int dct_quantize_trellis_c(MpegEncContext *s, DCTELEM *block, int n, int qscale, int *overflow);
+static int sse_mb(MpegEncContext *s);
#endif //CONFIG_ENCODERS
+#ifdef HAVE_XVMC
+extern int XVMC_field_start(MpegEncContext*s, AVCodecContext *avctx);
+extern void XVMC_field_end(MpegEncContext *s);
+extern void XVMC_decode_mb(MpegEncContext *s, DCTELEM block[6][64]);
+#endif
+
void (*draw_edges)(uint8_t *buf, int wrap, int width, int height, int w)= draw_edges_c;
@@ -134,6 +140,13 @@ static void convert_matrix(MpegEncContext *s, int (*qmat)[64], uint16_t (*qmat16
}
}
}
+
+static inline void update_qscale(MpegEncContext *s){
+ s->qscale= (s->lambda*139 + FF_LAMBDA_SCALE*64) >> (FF_LAMBDA_SHIFT + 7);
+ s->qscale= clip(s->qscale, s->avctx->qmin, s->avctx->qmax);
+
+ s->lambda2= (s->lambda*s->lambda + FF_LAMBDA_SCALE/2) >> FF_LAMBDA_SHIFT;
+}
#endif //CONFIG_ENCODERS
void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable){
@@ -160,6 +173,20 @@ void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_s
}
}
+#ifdef CONFIG_ENCODERS
+void ff_write_quant_matrix(PutBitContext *pb, int16_t *matrix){
+ int i;
+
+ if(matrix){
+ put_bits(pb, 1, 1);
+ for(i=0;i<64;i++) {
+ put_bits(pb, 8, matrix[ ff_zigzag_direct[i] ]);
+ }
+ }else
+ put_bits(pb, 1, 0);
+}
+#endif //CONFIG_ENCODERS
+
/* init common dct for both encoder and decoder */
int DCT_common_init(MpegEncContext *s)
{
@@ -212,6 +239,11 @@ int DCT_common_init(MpegEncContext *s)
return 0;
}
+static void copy_picture(Picture *dst, Picture *src){
+ *dst = *src;
+ dst->type= FF_BUFFER_TYPE_COPY;
+}
+
/**
* allocates a Picture
* The pixels are allocated/set by calling get_buffer() if shared=0
@@ -270,6 +302,7 @@ static int alloc_picture(MpegEncContext *s, Picture *pic, int shared){
}
}
pic->qstride= s->mb_stride;
+ CHECKED_ALLOCZ(pic->pan_scan , 1 * sizeof(AVPanScan))
}
//it might be nicer if the application would keep track of these but it would require a API change
@@ -300,6 +333,7 @@ static void free_picture(MpegEncContext *s, Picture *pic){
av_freep(&pic->mbskip_table);
av_freep(&pic->qscale_table);
av_freep(&pic->mb_type_base);
+ av_freep(&pic->pan_scan);
pic->mb_type= NULL;
for(i=0; i<2; i++){
av_freep(&pic->motion_val[i]);
@@ -353,6 +387,11 @@ int MPV_common_init(MpegEncContext *s)
+ (toupper((s->avctx->codec_tag>>16)&0xFF)<<16)
+ (toupper((s->avctx->codec_tag>>24)&0xFF)<<24);
+ s->avctx->stream_codec_tag= toupper( s->avctx->stream_codec_tag &0xFF)
+ + (toupper((s->avctx->stream_codec_tag>>8 )&0xFF)<<8 )
+ + (toupper((s->avctx->stream_codec_tag>>16)&0xFF)<<16)
+ + (toupper((s->avctx->stream_codec_tag>>24)&0xFF)<<24);
+
CHECKED_ALLOCZ(s->allocated_edge_emu_buffer, (s->width+64)*2*17*2); //(width + edge + align)*interlaced*MBsize*tolerance
s->edge_emu_buffer= s->allocated_edge_emu_buffer + (s->width+64)*2*17;
@@ -401,6 +440,8 @@ int MPV_common_init(MpegEncContext *s)
/* Allocate MB type table */
CHECKED_ALLOCZ(s->mb_type , mb_array_size * sizeof(uint8_t)) //needed for encoding
+
+ CHECKED_ALLOCZ(s->lambda_table, mb_array_size * sizeof(int))
}
CHECKED_ALLOCZ(s->error_status_table, mb_array_size*sizeof(uint8_t))
@@ -476,6 +517,9 @@ void MPV_common_end(MpegEncContext *s)
{
int i;
+ av_freep(&s->parse_context.buffer);
+ s->parse_context.buffer_size=0;
+
av_freep(&s->mb_type);
av_freep(&s->p_mv_table_base);
av_freep(&s->b_forw_mv_table_base);
@@ -513,12 +557,16 @@ void MPV_common_end(MpegEncContext *s)
av_freep(&s->ac_stats);
av_freep(&s->error_status_table);
av_freep(&s->mb_index2xy);
+ av_freep(&s->lambda_table);
for(i=0; i<MAX_PICTURE_COUNT; i++){
free_picture(s, &s->picture[i]);
}
avcodec_default_free_buffers(s->avctx);
s->context_initialized = 0;
+ s->last_picture_ptr=
+ s->next_picture_ptr=
+ s->current_picture_ptr= NULL;
}
#ifdef CONFIG_ENCODERS
@@ -527,9 +575,11 @@ void MPV_common_end(MpegEncContext *s)
int MPV_encode_init(AVCodecContext *avctx)
{
MpegEncContext *s = avctx->priv_data;
- int i;
+ int i, dummy;
int chroma_h_shift, chroma_v_shift;
+ avctx->pix_fmt = PIX_FMT_YUV420P; // FIXME
+
s->bit_rate = avctx->bit_rate;
s->bit_rate_tolerance = avctx->bit_rate_tolerance;
s->width = avctx->width;
@@ -594,7 +644,7 @@ int MPV_encode_init(AVCodecContext *avctx)
return -1;
}
- if(s->max_b_frames && s->codec_id != CODEC_ID_MPEG4 && s->codec_id != CODEC_ID_MPEG1VIDEO){
+ if(s->max_b_frames && s->codec_id != CODEC_ID_MPEG4 && s->codec_id != CODEC_ID_MPEG1VIDEO && s->codec_id != CODEC_ID_MPEG2VIDEO){
fprintf(stderr, "b frames not supporetd by codec\n");
return -1;
}
@@ -604,10 +654,15 @@ int MPV_encode_init(AVCodecContext *avctx)
return -1;
}
+ if((s->flags & CODEC_FLAG_CBP_RD) && !(s->flags & CODEC_FLAG_TRELLIS_QUANT)){
+ fprintf(stderr, "CBP RD needs trellis quant\n");
+ return -1;
+ }
+
if(s->codec_id==CODEC_ID_MJPEG){
s->intra_quant_bias= 1<<(QUANT_BIAS_SHIFT-1); //(a + x/2)/x
s->inter_quant_bias= 0;
- }else if(s->mpeg_quant || s->codec_id==CODEC_ID_MPEG1VIDEO){
+ }else if(s->mpeg_quant || s->codec_id==CODEC_ID_MPEG1VIDEO || s->codec_id==CODEC_ID_MPEG2VIDEO){
s->intra_quant_bias= 3<<(QUANT_BIAS_SHIFT-3); //(a + x*3/8)/x
s->inter_quant_bias= 0;
}else{
@@ -622,12 +677,22 @@ int MPV_encode_init(AVCodecContext *avctx)
avcodec_get_chroma_sub_sample(avctx->pix_fmt, &chroma_h_shift, &chroma_v_shift);
+ av_reduce(&s->time_increment_resolution, &dummy, s->avctx->frame_rate, s->avctx->frame_rate_base, (1<<16)-1);
+ s->time_increment_bits = av_log2(s->time_increment_resolution - 1) + 1;
+
switch(avctx->codec->id) {
case CODEC_ID_MPEG1VIDEO:
s->out_format = FMT_MPEG1;
s->low_delay= 0; //s->max_b_frames ? 0 : 1;
avctx->delay= s->low_delay ? 0 : (s->max_b_frames + 1);
break;
+ case CODEC_ID_MPEG2VIDEO:
+ s->out_format = FMT_MPEG1;
+ s->low_delay= 0; //s->max_b_frames ? 0 : 1;
+ avctx->delay= s->low_delay ? 0 : (s->max_b_frames + 1);
+ s->rtp_mode= 1; // mpeg2 must have slices
+ if(s->rtp_payload_size == 0) s->rtp_payload_size= 256*256*256;
+ break;
case CODEC_ID_LJPEG:
case CODEC_ID_MJPEG:
s->out_format = FMT_MJPEG;
@@ -667,6 +732,14 @@ int MPV_encode_init(AVCodecContext *avctx)
avctx->delay=0;
s->low_delay=1;
break;
+ case CODEC_ID_FLV1:
+ s->out_format = FMT_H263;
+ s->h263_flv = 2; /* format = 1; 11-bit codes */
+ s->unrestricted_mv = 1;
+ s->rtp_mode=0; /* don't allow GOB */
+ avctx->delay=0;
+ s->low_delay=1;
+ break;
case CODEC_ID_RV10:
s->out_format = FMT_H263;
s->h263_rv10 = 1;
@@ -790,10 +863,14 @@ int MPV_encode_init(AVCodecContext *avctx)
s->inter_matrix[j] = ff_mpeg1_default_non_intra_matrix[i];
}else
#endif
- { /* mpeg1 */
+ { /* mpeg1/2 */
s->intra_matrix[j] = ff_mpeg1_default_intra_matrix[i];
s->inter_matrix[j] = ff_mpeg1_default_non_intra_matrix[i];
}
+ if(s->avctx->intra_matrix)
+ s->intra_matrix[j] = s->avctx->intra_matrix[i];
+ if(s->avctx->inter_matrix)
+ s->inter_matrix[j] = s->avctx->inter_matrix[i];
}
/* precompute matrix */
@@ -831,6 +908,8 @@ int MPV_encode_end(AVCodecContext *avctx)
MPV_common_end(s);
if (s->out_format == FMT_MJPEG)
mjpeg_close(s);
+
+ av_freep(&avctx->extradata);
return 0;
}
@@ -935,7 +1014,7 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
assert(s->last_picture_ptr==NULL || s->out_format != FMT_H264 || s->codec_id == CODEC_ID_SVQ3);
/* mark&release old frames */
- if (s->pict_type != B_TYPE && s->last_picture_ptr) {
+ if (s->pict_type != B_TYPE && s->last_picture_ptr && s->last_picture_ptr->data[0]) {
avctx->release_buffer(avctx, (AVFrame*)s->last_picture_ptr);
/* release forgotten pictures */
@@ -966,16 +1045,18 @@ alloc:
if(s->current_picture_ptr)
pic->coded_picture_number= s->current_picture_ptr->coded_picture_number+1;
- alloc_picture(s, (Picture*)pic, 0);
+ if( alloc_picture(s, (Picture*)pic, 0) < 0)
+ return -1;
s->current_picture_ptr= &s->picture[i];
}
s->current_picture_ptr->pict_type= s->pict_type;
- s->current_picture_ptr->quality= s->qscale;
+// if(s->flags && CODEC_FLAG_QSCALE)
+ // s->current_picture_ptr->quality= s->new_picture_ptr->quality;
s->current_picture_ptr->key_frame= s->pict_type == I_TYPE;
- s->current_picture= *s->current_picture_ptr;
+ copy_picture(&s->current_picture, s->current_picture_ptr);
if(s->out_format != FMT_H264 || s->codec_id == CODEC_ID_SVQ3){
if (s->pict_type != B_TYPE) {
@@ -983,10 +1064,17 @@ alloc:
s->next_picture_ptr= s->current_picture_ptr;
}
- if(s->last_picture_ptr) s->last_picture= *s->last_picture_ptr;
- if(s->next_picture_ptr) s->next_picture= *s->next_picture_ptr;
- if(s->new_picture_ptr ) s->new_picture = *s->new_picture_ptr;
+ if(s->last_picture_ptr) copy_picture(&s->last_picture, s->last_picture_ptr);
+ if(s->next_picture_ptr) copy_picture(&s->next_picture, s->next_picture_ptr);
+ if(s->pict_type != I_TYPE && (s->last_picture_ptr==NULL || s->last_picture_ptr->data[0]==NULL)){
+ fprintf(stderr, "warning: first frame is no keyframe\n");
+ assert(s->pict_type != B_TYPE); //these should have been dropped if we dont have a reference
+ goto alloc;
+ }
+
+ assert(s->pict_type == I_TYPE || (s->last_picture_ptr && s->last_picture_ptr->data[0]));
+
if(s->picture_structure!=PICT_FRAME){
int i;
for(i=0; i<4; i++){
@@ -998,12 +1086,6 @@ alloc:
s->next_picture.linesize[i] *=2;
}
}
-
- if(s->pict_type != I_TYPE && s->last_picture_ptr==NULL){
- fprintf(stderr, "warning: first frame is no keyframe\n");
- assert(s->pict_type != B_TYPE); //these should have been dropped if we dont have a reference
- goto alloc;
- }
}
s->hurry_up= s->avctx->hurry_up;
@@ -1011,14 +1093,17 @@ alloc:
/* set dequantizer, we cant do it during init as it might change for mpeg4
and we cant do it in the header decode as init isnt called for mpeg4 there yet */
- if(s->out_format == FMT_H263){
- if(s->mpeg_quant)
- s->dct_unquantize = s->dct_unquantize_mpeg2;
- else
- s->dct_unquantize = s->dct_unquantize_h263;
- }else
+ if(s->mpeg_quant || s->codec_id == CODEC_ID_MPEG2VIDEO)
+ s->dct_unquantize = s->dct_unquantize_mpeg2;
+ else if(s->out_format == FMT_H263)
+ s->dct_unquantize = s->dct_unquantize_h263;
+ else
s->dct_unquantize = s->dct_unquantize_mpeg1;
+#ifdef HAVE_XVMC
+ if(s->avctx->xvmc_acceleration)
+ return XVMC_field_start(s, avctx);
+#endif
return 0;
}
@@ -1027,12 +1112,16 @@ void MPV_frame_end(MpegEncContext *s)
{
int i;
/* draw edge for correct motion prediction if outside */
- if(s->codec_id!=CODEC_ID_SVQ1){
- if (s->pict_type != B_TYPE && !s->intra_only && !(s->flags&CODEC_FLAG_EMU_EDGE)) {
+#ifdef HAVE_XVMC
+//just to make sure that all data is rendered.
+ if(s->avctx->xvmc_acceleration){
+ XVMC_field_end(s);
+ }else
+#endif
+ if(s->unrestricted_mv && s->pict_type != B_TYPE && !s->intra_only && !(s->flags&CODEC_FLAG_EMU_EDGE)) {
draw_edges(s->current_picture.data[0], s->linesize , s->h_edge_pos , s->v_edge_pos , EDGE_WIDTH );
draw_edges(s->current_picture.data[1], s->uvlinesize, s->h_edge_pos>>1, s->v_edge_pos>>1, EDGE_WIDTH/2);
draw_edges(s->current_picture.data[2], s->uvlinesize, s->h_edge_pos>>1, s->v_edge_pos>>1, EDGE_WIDTH/2);
- }
}
emms_c();
@@ -1291,11 +1380,12 @@ static int get_intra_count(MpegEncContext *s, uint8_t *src, uint8_t *ref, int st
static int load_input_picture(MpegEncContext *s, AVFrame *pic_arg){
- AVFrame *pic;
+ AVFrame *pic=NULL;
int i;
const int encoding_delay= s->max_b_frames;
int direct=1;
-
+
+ if(pic_arg){
if(encoding_delay && !(s->flags&CODEC_FLAG_INPUT_PRESERVED)) direct=0;
if(pic_arg->linesize[0] != s->linesize) direct=0;
if(pic_arg->linesize[1] != s->uvlinesize) direct=0;
@@ -1315,26 +1405,20 @@ static int load_input_picture(MpegEncContext *s, AVFrame *pic_arg){
}
alloc_picture(s, (Picture*)pic, 1);
}else{
+ int offset= 16;
i= find_unused_picture(s, 0);
pic= (AVFrame*)&s->picture[i];
pic->reference= 3;
alloc_picture(s, (Picture*)pic, 0);
- for(i=0; i<4; i++){
- /* the input will be 16 pixels to the right relative to the actual buffer start
- * and the current_pic, so the buffer can be reused, yes its not beatifull
- */
- pic->data[i]+= 16;
- }
- if( pic->data[0] == pic_arg->data[0]
- && pic->data[1] == pic_arg->data[1]
- && pic->data[2] == pic_arg->data[2]){
+ if( pic->data[0] + offset == pic_arg->data[0]
+ && pic->data[1] + offset == pic_arg->data[1]
+ && pic->data[2] + offset == pic_arg->data[2]){
// empty
}else{
int h_chroma_shift, v_chroma_shift;
-
avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &h_chroma_shift, &v_chroma_shift);
for(i=0; i<3; i++){
@@ -1345,7 +1429,7 @@ static int load_input_picture(MpegEncContext *s, AVFrame *pic_arg){
int w= s->width >>h_shift;
int h= s->height>>v_shift;
uint8_t *src= pic_arg->data[i];
- uint8_t *dst= pic->data[i];
+ uint8_t *dst= pic->data[i] + offset;
if(src_stride==dst_stride)
memcpy(dst, src, src_stride*h);
@@ -1365,6 +1449,8 @@ static int load_input_picture(MpegEncContext *s, AVFrame *pic_arg){
if(s->input_picture[encoding_delay])
pic->display_picture_number= s->input_picture[encoding_delay]->display_picture_number + 1;
+
+ }
/* shift buffer entries */
for(i=1; i<MAX_PICTURE_COUNT /*s->encoding_delay+1*/; i++)
@@ -1377,7 +1463,6 @@ static int load_input_picture(MpegEncContext *s, AVFrame *pic_arg){
static void select_input_picture(MpegEncContext *s){
int i;
- const int encoding_delay= s->max_b_frames;
int coded_pic_num=0;
if(s->reordered_input_picture[0])
@@ -1418,16 +1503,17 @@ static void select_input_picture(MpegEncContext *s){
}
}else if(s->b_frame_strategy==0){
b_frames= s->max_b_frames;
+ while(b_frames && !s->input_picture[b_frames]) b_frames--;
}else if(s->b_frame_strategy==1){
for(i=1; i<s->max_b_frames+1; i++){
- if(s->input_picture[i]->b_frame_score==0){
+ if(s->input_picture[i] && s->input_picture[i]->b_frame_score==0){
s->input_picture[i]->b_frame_score=
get_intra_count(s, s->input_picture[i ]->data[0],
s->input_picture[i-1]->data[0], s->linesize) + 1;
}
}
for(i=0; i<s->max_b_frames; i++){
- if(s->input_picture[i]->b_frame_score - 1 > s->mb_num/40) break;
+ if(s->input_picture[i]==NULL || s->input_picture[i]->b_frame_score - 1 > s->mb_num/40) break;
}
b_frames= FFMAX(0, i-1);
@@ -1465,7 +1551,7 @@ static void select_input_picture(MpegEncContext *s){
if(s->reordered_input_picture[0]){
s->reordered_input_picture[0]->reference= s->reordered_input_picture[0]->pict_type!=B_TYPE ? 3 : 0;
- s->new_picture= *s->reordered_input_picture[0];
+ copy_picture(&s->new_picture, s->reordered_input_picture[0]);
if(s->reordered_input_picture[0]->type == FF_BUFFER_TYPE_SHARED){
// input is a shared pix, so we cant modifiy it -> alloc a new one & ensure that the shared one is reuseable
@@ -1483,6 +1569,7 @@ static void select_input_picture(MpegEncContext *s){
pic->quality = s->reordered_input_picture[0]->quality;
pic->coded_picture_number = s->reordered_input_picture[0]->coded_picture_number;
pic->reference = s->reordered_input_picture[0]->reference;
+ pic->pts = s->reordered_input_picture[0]->pts;
alloc_picture(s, pic, 0);
@@ -1495,11 +1582,10 @@ static void select_input_picture(MpegEncContext *s){
s->current_picture_ptr= s->reordered_input_picture[0];
for(i=0; i<4; i++){
- //reverse the +16 we did before storing the input
- s->current_picture_ptr->data[i]-=16;
+ s->new_picture.data[i]+=16;
}
}
- s->current_picture= *s->current_picture_ptr;
+ copy_picture(&s->current_picture, s->current_picture_ptr);
s->picture_number= s->new_picture.display_picture_number;
//printf("dpn:%d\n", s->picture_number);
@@ -1515,7 +1601,12 @@ int MPV_encode_picture(AVCodecContext *avctx,
AVFrame *pic_arg = data;
int i;
- init_put_bits(&s->pb, buf, buf_size, NULL, NULL);
+ if(avctx->pix_fmt != PIX_FMT_YUV420P){
+ fprintf(stderr, "this codec supports only YUV420P\n");
+ return -1;
+ }
+
+ init_put_bits(&s->pb, buf, buf_size);
s->picture_in_gop_number++;
@@ -1527,10 +1618,6 @@ int MPV_encode_picture(AVCodecContext *avctx,
if(s->new_picture.data[0]){
s->pict_type= s->new_picture.pict_type;
- if (s->fixed_qscale){ /* the ratecontrol needs the last qscale so we dont touch it for CBR */
- s->qscale= (int)(s->new_picture.quality+0.5);
- assert(s->qscale);
- }
//emms_c();
//printf("qs:%f %f %d\n", s->new_picture.quality, s->current_picture.quality, s->qscale);
MPV_frame_start(s, avctx);
@@ -1605,8 +1692,8 @@ static inline void gmc1_motion(MpegEncContext *s,
dest_y+=dest_offset;
if(s->flags&CODEC_FLAG_EMU_EDGE){
- if(src_x<0 || src_y<0 || src_x + 17 >= s->h_edge_pos
- || src_y + 17 >= s->v_edge_pos){
+ if( (unsigned)src_x >= s->h_edge_pos - 17
+ || (unsigned)src_y >= s->v_edge_pos - 17){
ff_emulated_edge_mc(s->edge_emu_buffer, ptr, linesize, 17, 17, src_x, src_y, s->h_edge_pos, s->v_edge_pos);
ptr= s->edge_emu_buffer;
}
@@ -1644,8 +1731,8 @@ static inline void gmc1_motion(MpegEncContext *s,
offset = (src_y * uvlinesize) + src_x + (src_offset>>1);
ptr = ref_picture[1] + offset;
if(s->flags&CODEC_FLAG_EMU_EDGE){
- if(src_x<0 || src_y<0 || src_x + 9 >= s->h_edge_pos>>1
- || src_y + 9 >= s->v_edge_pos>>1){
+ if( (unsigned)src_x >= (s->h_edge_pos>>1) - 9
+ || (unsigned)src_y >= (s->v_edge_pos>>1) - 9){
ff_emulated_edge_mc(s->edge_emu_buffer, ptr, uvlinesize, 9, 9, src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);
ptr= s->edge_emu_buffer;
emu=1;
@@ -1834,9 +1921,9 @@ if(s->quarter_sample)
ptr = ref_picture[0] + (src_y * linesize) + (src_x) + src_offset;
dest_y += dest_offset;
- if(s->flags&CODEC_FLAG_EMU_EDGE){
- if(src_x<0 || src_y<0 || src_x + (motion_x&1) + 16 > s->h_edge_pos
- || src_y + (motion_y&1) + h > v_edge_pos){
+ if(s->unrestricted_mv && (s->flags&CODEC_FLAG_EMU_EDGE)){
+ if( (unsigned)src_x > s->h_edge_pos - (motion_x&1) - 16
+ || (unsigned)src_y > v_edge_pos - (motion_y&1) - h){
ff_emulated_edge_mc(s->edge_emu_buffer, ptr - src_offset, s->linesize, 17, 17+field_based, //FIXME linesize? and uv below
src_x, src_y<<field_based, s->h_edge_pos, s->v_edge_pos);
ptr= s->edge_emu_buffer + src_offset;
@@ -1920,8 +2007,8 @@ static inline void qpel_motion(MpegEncContext *s,
//printf("%d %d %d\n", src_x, src_y, dxy);
if(s->flags&CODEC_FLAG_EMU_EDGE){
- if(src_x<0 || src_y<0 || src_x + (motion_x&3) + 16 > s->h_edge_pos
- || src_y + (motion_y&3) + h > v_edge_pos){
+ if( (unsigned)src_x > s->h_edge_pos - (motion_x&3) - 16
+ || (unsigned)src_y > v_edge_pos - (motion_y&3) - h ){
ff_emulated_edge_mc(s->edge_emu_buffer, ptr - src_offset, s->linesize, 17, 17+field_based,
src_x, src_y<<field_based, s->h_edge_pos, s->v_edge_pos);
ptr= s->edge_emu_buffer + src_offset;
@@ -2072,8 +2159,8 @@ static inline void MPV_motion(MpegEncContext *s,
ptr = ref_picture[0] + (src_y * s->linesize) + (src_x);
if(s->flags&CODEC_FLAG_EMU_EDGE){
- if(src_x<0 || src_y<0 || src_x + (motion_x&3) + 8 > s->h_edge_pos
- || src_y + (motion_y&3) + 8 > s->v_edge_pos){
+ if( (unsigned)src_x > s->h_edge_pos - (motion_x&3) - 8
+ || (unsigned)src_y > s->v_edge_pos - (motion_y&3) - 8 ){
ff_emulated_edge_mc(s->edge_emu_buffer, ptr, s->linesize, 9, 9, src_x, src_y, s->h_edge_pos, s->v_edge_pos);
ptr= s->edge_emu_buffer;
}
@@ -2103,8 +2190,8 @@ static inline void MPV_motion(MpegEncContext *s,
ptr = ref_picture[0] + (src_y * s->linesize) + (src_x);
if(s->flags&CODEC_FLAG_EMU_EDGE){
- if(src_x<0 || src_y<0 || src_x + (motion_x&1) + 8 > s->h_edge_pos
- || src_y + (motion_y&1) + 8 > s->v_edge_pos){
+ if( (unsigned)src_x > s->h_edge_pos - (motion_x&1) - 8
+ || (unsigned)src_y > s->v_edge_pos - (motion_y&1) - 8){
ff_emulated_edge_mc(s->edge_emu_buffer, ptr, s->linesize, 9, 9, src_x, src_y, s->h_edge_pos, s->v_edge_pos);
ptr= s->edge_emu_buffer;
}
@@ -2138,8 +2225,8 @@ static inline void MPV_motion(MpegEncContext *s,
offset = (src_y * (s->uvlinesize)) + src_x;
ptr = ref_picture[1] + offset;
if(s->flags&CODEC_FLAG_EMU_EDGE){
- if(src_x<0 || src_y<0 || src_x + (dxy &1) + 8 > s->h_edge_pos>>1
- || src_y + (dxy>>1) + 8 > s->v_edge_pos>>1){
+ if( (unsigned)src_x > (s->h_edge_pos>>1) - (dxy &1) - 8
+ || (unsigned)src_y > (s->v_edge_pos>>1) - (dxy>>1) - 8){
ff_emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9, src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);
ptr= s->edge_emu_buffer;
emu=1;
@@ -2194,6 +2281,105 @@ static inline void MPV_motion(MpegEncContext *s,
s->mv[dir][0][0], s->mv[dir][0][1], 16);
}
break;
+ case MV_TYPE_16X8:{
+ int offset;
+ uint8_t ** ref2picture;
+
+ if(s->picture_structure == s->field_select[dir][0] + 1 || s->pict_type == B_TYPE || s->first_field){
+ ref2picture= ref_picture;
+ offset= s->field_select[dir][0] ? s->linesize : 0;
+ }else{
+ ref2picture= s->current_picture.data;
+ offset= s->field_select[dir][0] ? s->linesize : -s->linesize;
+ }
+
+ mpeg_motion(s, dest_y, dest_cb, dest_cr, 0,
+ ref2picture, offset,
+ 0, pix_op,
+ s->mv[dir][0][0], s->mv[dir][0][1], 8);
+
+
+ if(s->picture_structure == s->field_select[dir][1] + 1 || s->pict_type == B_TYPE || s->first_field){
+ ref2picture= ref_picture;
+ offset= s->field_select[dir][1] ? s->linesize : 0;
+ }else{
+ ref2picture= s->current_picture.data;
+ offset= s->field_select[dir][1] ? s->linesize : -s->linesize;
+ }
+ // I know it is ugly but this is the only way to fool emu_edge without rewrite mpeg_motion
+ mpeg_motion(s, dest_y+16*s->linesize, dest_cb+8*s->uvlinesize, dest_cr+8*s->uvlinesize,
+ 0,
+ ref2picture, offset,
+ 0, pix_op,
+ s->mv[dir][1][0], s->mv[dir][1][1]+16, 8);
+ }
+
+ break;
+ case MV_TYPE_DMV:
+ {
+ op_pixels_func (*dmv_pix_op)[4];
+ int offset;
+
+ dmv_pix_op = s->dsp.put_pixels_tab;
+
+ if(s->picture_structure == PICT_FRAME){
+ //put top field from top field
+ mpeg_motion(s, dest_y, dest_cb, dest_cr, 0,
+ ref_picture, 0,
+ 1, dmv_pix_op,
+ s->mv[dir][0][0], s->mv[dir][0][1], 8);
+ //put bottom field from bottom field
+ mpeg_motion(s, dest_y, dest_cb, dest_cr, s->linesize,
+ ref_picture, s->linesize,
+ 1, dmv_pix_op,
+ s->mv[dir][0][0], s->mv[dir][0][1], 8);
+
+ dmv_pix_op = s->dsp.avg_pixels_tab;
+
+ //avg top field from bottom field
+ mpeg_motion(s, dest_y, dest_cb, dest_cr, 0,
+ ref_picture, s->linesize,
+ 1, dmv_pix_op,
+ s->mv[dir][2][0], s->mv[dir][2][1], 8);
+ //avg bottom field from top field
+ mpeg_motion(s, dest_y, dest_cb, dest_cr, s->linesize,
+ ref_picture, 0,
+ 1, dmv_pix_op,
+ s->mv[dir][3][0], s->mv[dir][3][1], 8);
+
+ }else{
+ offset=(s->picture_structure == PICT_BOTTOM_FIELD)?
+ s->linesize : 0;
+
+ //put field from the same parity
+ //same parity is never in the same frame
+ mpeg_motion(s, dest_y, dest_cb, dest_cr, 0,
+ ref_picture,offset,
+ 0,dmv_pix_op,
+ s->mv[dir][0][0],s->mv[dir][0][1],16);
+
+ // after put we make avg of the same block
+ dmv_pix_op=s->dsp.avg_pixels_tab;
+
+ //opposite parity is always in the same frame if this is second field
+ if(!s->first_field){
+ ref_picture = s->current_picture.data;
+ //top field is one linesize from frame beginig
+ offset=(s->picture_structure == PICT_BOTTOM_FIELD)?
+ -s->linesize : s->linesize;
+ }else
+ offset=(s->picture_structure == PICT_BOTTOM_FIELD)?
+ 0 : s->linesize;
+
+ //avg field from the opposite parity
+ mpeg_motion(s, dest_y, dest_cb, dest_cr,0,
+ ref_picture, offset,
+ 0,dmv_pix_op,
+ s->mv[dir][2][0],s->mv[dir][2][1],16);
+ }
+ }
+ break;
+
}
}
@@ -2272,6 +2458,12 @@ void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
{
int mb_x, mb_y;
const int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
+#ifdef HAVE_XVMC
+ if(s->avctx->xvmc_acceleration){
+ XVMC_decode_mb(s,block);
+ return;
+ }
+#endif
mb_x = s->mb_x;
mb_y = s->mb_y;
@@ -2292,50 +2484,6 @@ void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
else if (s->h263_pred || s->h263_aic)
s->mbintra_table[mb_xy]=1;
- /* update motion predictor, not for B-frames as they need the motion_val from the last P/S-Frame */
- if (s->out_format == FMT_H263 && s->pict_type!=B_TYPE) { //FIXME move into h263.c if possible, format specific stuff shouldnt be here
- //FIXME a lot of thet is only needed for !low_delay
- const int wrap = s->block_wrap[0];
- const int xy = s->block_index[0];
- if(s->mv_type != MV_TYPE_8X8){
- int motion_x, motion_y;
- if (s->mb_intra) {
- motion_x = 0;
- 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);
- for(i=0; i<2; i++){
- s->field_mv_table[mb_xy][i][0]= s->mv[0][i][0];
- s->field_mv_table[mb_xy][i][1]= s->mv[0][i][1];
- s->field_select_table[mb_xy][i]= s->field_select[0][i];
- }
- }
-
- /* no update if 8X8 because it has been done during parsing */
- s->motion_val[xy][0] = motion_x;
- s->motion_val[xy][1] = motion_y;
- s->motion_val[xy + 1][0] = motion_x;
- s->motion_val[xy + 1][1] = motion_y;
- s->motion_val[xy + wrap][0] = motion_x;
- s->motion_val[xy + wrap][1] = motion_y;
- s->motion_val[xy + 1 + wrap][0] = motion_x;
- s->motion_val[xy + 1 + wrap][1] = motion_y;
- }
-
- if(s->encoding){ //FIXME encoding MUST be cleaned up
- if (s->mv_type == MV_TYPE_8X8)
- s->current_picture.mb_type[mb_xy]= MB_TYPE_L0 | MB_TYPE_8x8;
- else
- s->current_picture.mb_type[mb_xy]= MB_TYPE_L0 | MB_TYPE_16x16;
- }
- }
-
if ((s->flags&CODEC_FLAG_PSNR) || !(s->encoding && (s->intra_only || s->pict_type==B_TYPE))) { //FIXME precalc
uint8_t *dest_y, *dest_cb, *dest_cr;
int dct_linesize, dct_offset;
@@ -2345,10 +2493,6 @@ void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
const int uvlinesize= s->current_picture.linesize[1];
/* avoid copy if macroblock skipped in last frame too */
- if (s->pict_type != B_TYPE) {
- s->current_picture.mbskip_table[mb_xy]= s->mb_skiped;
- }
-
/* skip only during decoding as we might trash the buffers during encoding a bit */
if(!s->encoding){
uint8_t *mbskip_ptr = &s->mbskip_table[mb_xy];
@@ -2373,17 +2517,6 @@ void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
} else{
*mbskip_ptr = 0; /* not skipped */
}
- }else
- s->mb_skiped= 0;
-
- if(s->pict_type==B_TYPE && s->avctx->draw_horiz_band && s->picture_structure==PICT_FRAME){ //FIXME precalc
- dest_y = s->current_picture.data[0] + mb_x * 16;
- dest_cb = s->current_picture.data[1] + mb_x * 8;
- dest_cr = s->current_picture.data[2] + mb_x * 8;
- }else{
- dest_y = s->current_picture.data[0] + (mb_y * 16* linesize ) + mb_x * 16;
- dest_cb = s->current_picture.data[1] + (mb_y * 8 * uvlinesize) + mb_x * 8;
- dest_cr = s->current_picture.data[2] + (mb_y * 8 * uvlinesize) + mb_x * 8;
}
if (s->interlaced_dct) {
@@ -2393,11 +2526,15 @@ void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
dct_linesize = linesize;
dct_offset = linesize * 8;
}
+
+ dest_y= s->dest[0];
+ dest_cb= s->dest[1];
+ dest_cr= s->dest[2];
if (!s->mb_intra) {
/* motion handling */
/* decoding or more than one mb_type (MC was allready done otherwise) */
- if((!s->encoding) || (s->mb_type[mb_xy]&(s->mb_type[mb_xy]-1))){
+ if(!s->encoding){
if ((!s->no_rounding) || s->pict_type==B_TYPE){
op_pix = s->dsp.put_pixels_tab;
op_qpix= s->dsp.put_qpel_pixels_tab;
@@ -2420,7 +2557,7 @@ void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
if(s->hurry_up>1) return;
/* add dct residue */
- if(s->encoding || !( s->mpeg2 || s->h263_msmpeg4 || s->codec_id==CODEC_ID_MPEG1VIDEO
+ if(s->encoding || !( s->h263_msmpeg4 || s->codec_id==CODEC_ID_MPEG1VIDEO || s->codec_id==CODEC_ID_MPEG2VIDEO
|| (s->codec_id==CODEC_ID_MPEG4 && !s->mpeg_quant))){
add_dequant_dct(s, block[0], 0, dest_y, dct_linesize);
add_dequant_dct(s, block[1], 1, dest_y + 8, dct_linesize);
@@ -2449,7 +2586,7 @@ void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
#endif
} else {
/* dct only in intra block */
- if(s->encoding || !(s->mpeg2 || s->codec_id==CODEC_ID_MPEG1VIDEO)){
+ if(s->encoding || !(s->codec_id==CODEC_ID_MPEG1VIDEO || s->codec_id==CODEC_ID_MPEG2VIDEO)){
put_dct(s, block[0], 0, dest_y, dct_linesize);
put_dct(s, block[1], 1, dest_y + 8, dct_linesize);
put_dct(s, block[2], 2, dest_y + dct_offset, dct_linesize);
@@ -2619,33 +2756,66 @@ static int pix_diff_vcmp16x8(uint8_t *s1, uint8_t*s2, int stride){ //FIXME move
* @param h is the normal height, this will be reduced automatically if needed for the last row
*/
void ff_draw_horiz_band(MpegEncContext *s, int y, int h){
- if ( s->avctx->draw_horiz_band
- && (s->last_picture_ptr || s->low_delay) ) {
- uint8_t *src_ptr[3];
- int offset;
+ if (s->avctx->draw_horiz_band) {
+ AVFrame *src;
+ int offset[4];
+
+ if(s->picture_structure != PICT_FRAME){
+ h <<= 1;
+ y <<= 1;
+ if(s->first_field && !(s->avctx->slice_flags&SLICE_FLAG_ALLOW_FIELD)) return;
+ }
+
h= FFMIN(h, s->height - y);
- if(s->pict_type==B_TYPE && s->picture_structure == PICT_FRAME)
- offset = 0;
+ if(s->pict_type==B_TYPE || s->low_delay || (s->avctx->slice_flags&SLICE_FLAG_CODED_ORDER))
+ src= (AVFrame*)s->current_picture_ptr;
+ else if(s->last_picture_ptr)
+ src= (AVFrame*)s->last_picture_ptr;
else
- offset = y * s->linesize;
-
- if(s->pict_type==B_TYPE || s->low_delay){
- src_ptr[0] = s->current_picture.data[0] + offset;
- src_ptr[1] = s->current_picture.data[1] + (offset >> 2);
- src_ptr[2] = s->current_picture.data[2] + (offset >> 2);
- } else {
- src_ptr[0] = s->last_picture.data[0] + offset;
- src_ptr[1] = s->last_picture.data[1] + (offset >> 2);
- src_ptr[2] = s->last_picture.data[2] + (offset >> 2);
+ return;
+
+ if(s->pict_type==B_TYPE && s->picture_structure == PICT_FRAME && s->out_format != FMT_H264){
+ offset[0]=
+ offset[1]=
+ offset[2]=
+ offset[3]= 0;
+ }else{
+ offset[0]= y * s->linesize;;
+ offset[1]=
+ offset[2]= (y>>1) * s->uvlinesize;;
+ offset[3]= 0;
}
+
emms_c();
- s->avctx->draw_horiz_band(s->avctx, src_ptr, s->linesize,
- y, s->width, h);
+ s->avctx->draw_horiz_band(s->avctx, src, offset,
+ y, s->picture_structure, h);
}
}
+void ff_init_block_index(MpegEncContext *s){ //FIXME maybe rename
+ const int linesize= s->current_picture.linesize[0]; //not s->linesize as this woulnd be wrong for field pics
+ const int uvlinesize= s->current_picture.linesize[1];
+
+ s->block_index[0]= s->block_wrap[0]*(s->mb_y*2 + 1) - 1 + s->mb_x*2;
+ s->block_index[1]= s->block_wrap[0]*(s->mb_y*2 + 1) + s->mb_x*2;
+ s->block_index[2]= s->block_wrap[0]*(s->mb_y*2 + 2) - 1 + s->mb_x*2;
+ s->block_index[3]= s->block_wrap[0]*(s->mb_y*2 + 2) + s->mb_x*2;
+ s->block_index[4]= s->block_wrap[4]*(s->mb_y + 1) + s->block_wrap[0]*(s->mb_height*2 + 2) + s->mb_x;
+ s->block_index[5]= s->block_wrap[4]*(s->mb_y + 1 + s->mb_height + 2) + s->block_wrap[0]*(s->mb_height*2 + 2) + s->mb_x;
+
+ if(s->pict_type==B_TYPE && s->avctx->draw_horiz_band && s->picture_structure==PICT_FRAME){
+ s->dest[0] = s->current_picture.data[0] + s->mb_x * 16 - 16;
+ s->dest[1] = s->current_picture.data[1] + s->mb_x * 8 - 8;
+ s->dest[2] = s->current_picture.data[2] + s->mb_x * 8 - 8;
+ }else{
+ s->dest[0] = s->current_picture.data[0] + (s->mb_y * 16* linesize ) + s->mb_x * 16 - 16;
+ s->dest[1] = s->current_picture.data[1] + (s->mb_y * 8 * uvlinesize) + s->mb_x * 8 - 8;
+ s->dest[2] = s->current_picture.data[2] + (s->mb_y * 8 * uvlinesize) + s->mb_x * 8 - 8;
+ }
+}
+
#ifdef CONFIG_ENCODERS
static void encode_mb(MpegEncContext *s, int motion_x, int motion_y)
@@ -2659,22 +2829,23 @@ static void encode_mb(MpegEncContext *s, int motion_x, int motion_y)
for(i=0; i<6; i++) skip_dct[i]=0;
if(s->adaptive_quant){
- s->dquant= s->current_picture.qscale_table[mb_x + mb_y*s->mb_stride] - s->qscale;
+ const int last_qp= s->qscale;
+ const int mb_xy= mb_x + mb_y*s->mb_stride;
- if(s->out_format==FMT_H263){
- if (s->dquant> 2) s->dquant= 2;
- else if(s->dquant<-2) s->dquant=-2;
- }
+ s->lambda= s->lambda_table[mb_xy];
+ update_qscale(s);
+ s->dquant= s->qscale - last_qp;
+
+ if(s->out_format==FMT_H263)
+ s->dquant= clip(s->dquant, -2, 2); //FIXME RD
if(s->codec_id==CODEC_ID_MPEG4){
if(!s->mb_intra){
- if(s->mv_dir&MV_DIRECT)
+ if((s->mv_dir&MV_DIRECT) || s->mv_type==MV_TYPE_8X8)
s->dquant=0;
-
- assert(s->dquant==0 || s->mv_type!=MV_TYPE_8X8);
}
}
- s->qscale+= s->dquant;
+ s->qscale= last_qp + s->dquant;
s->y_dc_scale= s->y_dc_scale_table[ s->qscale ];
s->c_dc_scale= s->c_dc_scale_table[ s->qscale ];
}
@@ -2740,9 +2911,9 @@ static void encode_mb(MpegEncContext *s, int motion_x, int motion_y)
int wrap_y, wrap_c;
int emu=0;
- dest_y = s->current_picture.data[0] + (mb_y * 16 * s->linesize ) + mb_x * 16;
- dest_cb = s->current_picture.data[1] + (mb_y * 8 * (s->uvlinesize)) + mb_x * 8;
- dest_cr = s->current_picture.data[2] + (mb_y * 8 * (s->uvlinesize)) + mb_x * 8;
+ dest_y = s->dest[0];
+ dest_cb = s->dest[1];
+ dest_cr = s->dest[2];
wrap_y = s->linesize;
wrap_c = s->uvlinesize;
ptr_y = s->new_picture.data[0] + (mb_y * 16 * wrap_y) + mb_x * 16;
@@ -2837,19 +3008,6 @@ static void encode_mb(MpegEncContext *s, int motion_x, int motion_y)
}
-#if 0
- {
- float adap_parm;
-
- adap_parm = ((s->avg_mb_var << 1) + s->mb_var[s->mb_stride*mb_y+mb_x] + 1.0) /
- ((s->mb_var[s->mb_stride*mb_y+mb_x] << 1) + s->avg_mb_var + 1.0);
-
- printf("\ntype=%c qscale=%2d adap=%0.2f dquant=%4.2f var=%4d avgvar=%4d",
- (s->mb_type[s->mb_stride*mb_y+mb_x] > 0) ? 'I' : 'P',
- s->qscale, adap_parm, s->qscale*adap_parm,
- s->mb_var[s->mb_stride*mb_y+mb_x], s->avg_mb_var);
- }
-#endif
/* DCT & quantize */
if(s->out_format==FMT_MJPEG){
for(i=0;i<6;i++) {
@@ -2869,12 +3027,20 @@ static void encode_mb(MpegEncContext *s, int motion_x, int motion_y)
}else
s->block_last_index[i]= -1;
}
+
if(s->luma_elim_threshold && !s->mb_intra)
for(i=0; i<4; i++)
dct_single_coeff_elimination(s, i, s->luma_elim_threshold);
if(s->chroma_elim_threshold && !s->mb_intra)
for(i=4; i<6; i++)
dct_single_coeff_elimination(s, i, s->chroma_elim_threshold);
+
+ if(s->flags & CODEC_FLAG_CBP_RD){
+ for(i=0;i<6;i++) {
+ if(s->block_last_index[i] == -1)
+ s->coded_score[i]= INT_MAX/256;
+ }
+ }
}
if((s->flags&CODEC_FLAG_GRAY) && s->mb_intra){
@@ -2887,6 +3053,7 @@ static void encode_mb(MpegEncContext *s, int motion_x, int motion_y)
/* huffman encode */
switch(s->codec_id){ //FIXME funct ptr could be slightly faster
case CODEC_ID_MPEG1VIDEO:
+ case CODEC_ID_MPEG2VIDEO:
mpeg1_encode_mb(s, s->block, motion_x, motion_y); break;
#ifdef CONFIG_RISKY
case CODEC_ID_MPEG4:
@@ -2899,6 +3066,7 @@ static void encode_mb(MpegEncContext *s, int motion_x, int motion_y)
ff_wmv2_encode_mb(s, s->block, motion_x, motion_y); break;
case CODEC_ID_H263:
case CODEC_ID_H263P:
+ case CODEC_ID_FLV1:
case CODEC_ID_RV10:
h263_encode_mb(s, s->block, motion_x, motion_y); break;
#endif
@@ -2969,6 +3137,25 @@ int ff_combine_frame( MpegEncContext *s, int next, uint8_t **buf, int *buf_size)
return 0;
}
+void ff_mpeg_flush(AVCodecContext *avctx){
+ int i;
+ MpegEncContext *s = avctx->priv_data;
+
+ for(i=0; i<MAX_PICTURE_COUNT; i++){
+ if(s->picture[i].data[0] && ( s->picture[i].type == FF_BUFFER_TYPE_INTERNAL
+ || s->picture[i].type == FF_BUFFER_TYPE_USER))
+ avctx->release_buffer(avctx, (AVFrame*)&s->picture[i]);
+ }
+ s->last_picture_ptr = s->next_picture_ptr = NULL;
+
+ s->parse_context.state= -1;
+ s->parse_context.frame_start_found= 0;
+ s->parse_context.overread= 0;
+ s->parse_context.overread_index= 0;
+ s->parse_context.index= 0;
+ s->parse_context.last_index= 0;
+}
+
#ifdef CONFIG_ENCODERS
void ff_copy_bits(PutBitContext *pb, uint8_t *src, int length)
{
@@ -3003,7 +3190,7 @@ static inline void copy_context_before_encode(MpegEncContext *d, MpegEncContext
d->misc_bits= s->misc_bits;
d->last_bits= 0;
- d->mb_skiped= s->mb_skiped;
+ d->mb_skiped= 0;
d->qscale= s->qscale;
}
@@ -3048,7 +3235,8 @@ static inline void encode_mb_hq(MpegEncContext *s, MpegEncContext *backup, MpegE
PutBitContext pb[2], PutBitContext pb2[2], PutBitContext tex_pb[2],
int *dmin, int *next_block, int motion_x, int motion_y)
{
- int bits_count;
+ int score;
+ uint8_t *dest_backup[3];
copy_context_before_encode(s, backup, type);
@@ -3058,24 +3246,44 @@ static inline void encode_mb_hq(MpegEncContext *s, MpegEncContext *backup, MpegE
s->pb2 = pb2 [*next_block];
s->tex_pb= tex_pb[*next_block];
}
+
+ if(*next_block){
+ memcpy(dest_backup, s->dest, sizeof(s->dest));
+ s->dest[0] = s->me.scratchpad;
+ s->dest[1] = s->me.scratchpad + 16;
+ s->dest[2] = s->me.scratchpad + 16 + 8;
+ assert(2*s->uvlinesize == s->linesize); //should be no prob for encoding
+ assert(s->linesize >= 64); //FIXME
+ }
encode_mb(s, motion_x, motion_y);
-
- bits_count= get_bit_count(&s->pb);
+
+ score= get_bit_count(&s->pb);
if(s->data_partitioning){
- bits_count+= get_bit_count(&s->pb2);
- bits_count+= get_bit_count(&s->tex_pb);
+ score+= get_bit_count(&s->pb2);
+ score+= get_bit_count(&s->tex_pb);
+ }
+
+ if(s->avctx->mb_decision == FF_MB_DECISION_RD){
+ MPV_decode_mb(s, s->block);
+
+ score *= s->lambda2;
+ score += sse_mb(s) << FF_LAMBDA_SHIFT;
+ }
+
+ if(*next_block){
+ memcpy(s->dest, dest_backup, sizeof(s->dest));
}
- if(bits_count<*dmin){
- *dmin= bits_count;
+ if(score<*dmin){
+ *dmin= score;
*next_block^=1;
copy_context_after_encode(best, s, type);
}
}
-static inline int sse(MpegEncContext *s, uint8_t *src1, uint8_t *src2, int w, int h, int stride){
+static int sse(MpegEncContext *s, uint8_t *src1, uint8_t *src2, int w, int h, int stride){
uint32_t *sq = squareTbl + 256;
int acc=0;
int x,y;
@@ -3096,6 +3304,23 @@ static inline int sse(MpegEncContext *s, uint8_t *src1, uint8_t *src2, int w, in
return acc;
}
+static int sse_mb(MpegEncContext *s){
+ int w= 16;
+ int h= 16;
+
+ if(s->mb_x*16 + 16 > s->width ) w= s->width - s->mb_x*16;
+ if(s->mb_y*16 + 16 > s->height) h= s->height- s->mb_y*16;
+
+ if(w==16 && h==16)
+ return s->dsp.sse[0](NULL, s->new_picture.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], s->linesize)
+ +s->dsp.sse[1](NULL, s->new_picture.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[1], s->uvlinesize)
+ +s->dsp.sse[1](NULL, s->new_picture.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[2], s->uvlinesize);
+ else
+ return sse(s, s->new_picture.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], w, h, s->linesize)
+ +sse(s, s->new_picture.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[1], w>>1, h>>1, s->uvlinesize)
+ +sse(s, s->new_picture.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[2], w>>1, h>>1, s->uvlinesize);
+}
+
static void encode_picture(MpegEncContext *s, int picture_number)
{
int mb_x, mb_y, pdif = 0;
@@ -3108,9 +3333,9 @@ static void encode_picture(MpegEncContext *s, int picture_number)
PutBitContext pb[2], pb2[2], tex_pb[2];
for(i=0; i<2; i++){
- init_put_bits(&pb [i], bit_buf [i], 3000, NULL, NULL);
- init_put_bits(&pb2 [i], bit_buf2 [i], 3000, NULL, NULL);
- init_put_bits(&tex_pb[i], bit_buf_tex[i], 3000, NULL, NULL);
+ init_put_bits(&pb [i], bit_buf [i], 3000);
+ init_put_bits(&pb2 [i], bit_buf2 [i], 3000);
+ init_put_bits(&tex_pb[i], bit_buf_tex[i], 3000);
}
s->picture_number = picture_number;
@@ -3122,13 +3347,13 @@ static void encode_picture(MpegEncContext *s, int picture_number)
#ifdef CONFIG_RISKY
/* we need to initialize some time vars before we can encode b-frames */
// RAL: Condition added for MPEG1VIDEO
- if (s->codec_id == CODEC_ID_MPEG1VIDEO || (s->h263_pred && !s->h263_msmpeg4))
+ if (s->codec_id == CODEC_ID_MPEG1VIDEO || s->codec_id == CODEC_ID_MPEG2VIDEO || (s->h263_pred && !s->h263_msmpeg4))
ff_set_mpeg4_time(s, s->picture_number);
#endif
s->scene_change_score=0;
- s->qscale= (int)(s->frame_qscale + 0.5); //FIXME qscale / ... stuff for ME ratedistoration
+ s->lambda= s->current_picture_ptr->quality; //FIXME qscale / ... stuff for ME ratedistoration
if(s->pict_type==I_TYPE){
if(s->msmpeg4_version >= 3) s->no_rounding=1;
@@ -3208,7 +3433,7 @@ static void encode_picture(MpegEncContext *s, int picture_number)
}
emms_c();
- if(s->scene_change_score > 0 && s->pict_type == P_TYPE){
+ if(s->scene_change_score > s->avctx->scenechange_threshold && s->pict_type == P_TYPE){
s->pict_type= I_TYPE;
memset(s->mb_type , MB_TYPE_INTRA, sizeof(uint8_t)*s->mb_stride*s->mb_height);
//printf("Scene change detected, encoding as I Frame %d %d\n", s->current_picture.mb_var_sum, s->current_picture.mc_mb_var_sum);
@@ -3241,10 +3466,8 @@ static void encode_picture(MpegEncContext *s, int picture_number)
}
#endif
- if (s->fixed_qscale)
- s->frame_qscale = s->current_picture.quality;
- else
- s->frame_qscale = ff_rate_estimate_qscale(s);
+ if (!s->fixed_qscale)
+ s->current_picture.quality = ff_rate_estimate_qscale(s);
if(s->adaptive_quant){
#ifdef CONFIG_RISKY
@@ -3254,14 +3477,21 @@ static void encode_picture(MpegEncContext *s, int picture_number)
break;
case CODEC_ID_H263:
case CODEC_ID_H263P:
+ case CODEC_ID_FLV1:
ff_clean_h263_qscales(s);
break;
}
#endif
- s->qscale= s->current_picture.qscale_table[0];
+ s->lambda= s->lambda_table[0];
+ //FIXME broken
}else
- s->qscale= (int)(s->frame_qscale + 0.5);
+ s->lambda= s->current_picture.quality;
+//printf("%d %d\n", s->avctx->global_quality, s->current_picture.quality);
+ update_qscale(s);
+
+ if(s->qscale < 3 && s->max_qcoeff<=128 && s->pict_type==I_TYPE && !(s->flags & CODEC_FLAG_QSCALE))
+ s->qscale= 3; //reduce cliping problems
if (s->out_format == FMT_MJPEG) {
/* for mjpeg, we do include qscale in the matrix */
@@ -3297,6 +3527,8 @@ static void encode_picture(MpegEncContext *s, int picture_number)
mpeg4_encode_picture_header(s, picture_number);
else if (s->h263_rv10)
rv10_encode_picture_header(s, picture_number);
+ else if (s->codec_id == CODEC_ID_FLV1)
+ ff_flv_encode_picture_header(s, picture_number);
else
h263_encode_picture_header(s, picture_number);
break;
@@ -3304,6 +3536,8 @@ static void encode_picture(MpegEncContext *s, int picture_number)
case FMT_MPEG1:
mpeg1_encode_picture_header(s, picture_number);
break;
+ case FMT_H264:
+ break;
}
bits= get_bit_count(&s->pb);
s->header_bits= bits - s->last_bits;
@@ -3333,11 +3567,17 @@ static void encode_picture(MpegEncContext *s, int picture_number)
s->last_mv_dir = 0;
#ifdef CONFIG_RISKY
- if (s->codec_id==CODEC_ID_H263 || s->codec_id==CODEC_ID_H263P)
+ switch(s->codec_id){
+ case CODEC_ID_H263:
+ case CODEC_ID_H263P:
+ case CODEC_ID_FLV1:
s->gob_index = ff_h263_get_gob_height(s);
-
- if(s->codec_id==CODEC_ID_MPEG4 && s->partitioned_frame)
- ff_mpeg4_init_partitions(s);
+ break;
+ case CODEC_ID_MPEG4:
+ if(s->partitioned_frame)
+ ff_mpeg4_init_partitions(s);
+ break;
+ }
#endif
s->resync_mb_x=0;
@@ -3345,41 +3585,32 @@ static void encode_picture(MpegEncContext *s, int picture_number)
s->first_slice_line = 1;
s->ptr_lastgob = s->pb.buf;
for(mb_y=0; mb_y < s->mb_height; mb_y++) {
+ s->mb_x=0;
+ s->mb_y= mb_y;
+
s->y_dc_scale= s->y_dc_scale_table[ s->qscale ];
s->c_dc_scale= s->c_dc_scale_table[ s->qscale ];
+ ff_init_block_index(s);
- s->block_index[0]= s->block_wrap[0]*(mb_y*2 + 1) - 1;
- s->block_index[1]= s->block_wrap[0]*(mb_y*2 + 1);
- s->block_index[2]= s->block_wrap[0]*(mb_y*2 + 2) - 1;
- s->block_index[3]= s->block_wrap[0]*(mb_y*2 + 2);
- s->block_index[4]= s->block_wrap[4]*(mb_y + 1) + s->block_wrap[0]*(s->mb_height*2 + 2);
- s->block_index[5]= s->block_wrap[4]*(mb_y + 1 + s->mb_height + 2) + s->block_wrap[0]*(s->mb_height*2 + 2);
for(mb_x=0; mb_x < s->mb_width; mb_x++) {
const int xy= mb_y*s->mb_stride + mb_x;
int mb_type= s->mb_type[xy];
// int d;
- int dmin=10000000;
+ int dmin= INT_MAX;
s->mb_x = mb_x;
- s->mb_y = mb_y;
- s->block_index[0]+=2;
- s->block_index[1]+=2;
- s->block_index[2]+=2;
- s->block_index[3]+=2;
- s->block_index[4]++;
- s->block_index[5]++;
+ ff_update_block_index(s);
/* write gob / video packet header */
#ifdef CONFIG_RISKY
- if(s->rtp_mode){
+ if(s->rtp_mode && mb_y + mb_x>0){
int current_packet_size, is_gob_start;
current_packet_size= pbBufPtr(&s->pb) - s->ptr_lastgob;
is_gob_start=0;
if(s->codec_id==CODEC_ID_MPEG4){
- if(current_packet_size >= s->rtp_payload_size
- && s->mb_y + s->mb_x>0){
+ if(current_packet_size >= s->rtp_payload_size){
if(s->partitioned_frame){
ff_mpeg4_merge_partitions(s);
@@ -3397,14 +3628,21 @@ static void encode_picture(MpegEncContext *s, int picture_number)
}
}else if(s->codec_id==CODEC_ID_MPEG1VIDEO){
if( current_packet_size >= s->rtp_payload_size
- && s->mb_y + s->mb_x>0 && s->mb_skip_run==0){
+ && s->mb_skip_run==0){
+ ff_mpeg1_encode_slice_header(s);
+ ff_mpeg1_clean_buffers(s);
+ is_gob_start=1;
+ }
+ }else if(s->codec_id==CODEC_ID_MPEG2VIDEO){
+ if( ( current_packet_size >= s->rtp_payload_size || mb_x==0)
+ && s->mb_skip_run==0){
ff_mpeg1_encode_slice_header(s);
ff_mpeg1_clean_buffers(s);
is_gob_start=1;
}
}else{
if(current_packet_size >= s->rtp_payload_size
- && s->mb_x==0 && s->mb_y>0 && s->mb_y%s->gob_index==0){
+ && s->mb_x==0 && s->mb_y%s->gob_index==0){
h263_encode_gob_header(s, mb_y);
is_gob_start=1;
@@ -3425,6 +3663,8 @@ static void encode_picture(MpegEncContext *s, int picture_number)
s->first_slice_line=0;
}
+ s->mb_skiped=0;
+
if(mb_type & (mb_type-1)){ // more than 1 MB type possible
int next_block=0;
int pb_bits_count, pb2_bits_count, tex_pb_bits_count;
@@ -3447,6 +3687,15 @@ static void encode_picture(MpegEncContext *s, int picture_number)
encode_mb_hq(s, &backup_s, &best_s, MB_TYPE_INTER, pb, pb2, tex_pb,
&dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]);
}
+ if(mb_type&MB_TYPE_SKIPED){
+ s->mv_dir = MV_DIR_FORWARD;
+ s->mv_type = MV_TYPE_16X16;
+ s->mb_intra= 0;
+ s->mv[0][0][0] = 0;
+ s->mv[0][0][1] = 0;
+ encode_mb_hq(s, &backup_s, &best_s, MB_TYPE_SKIPED, pb, pb2, tex_pb,
+ &dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]);
+ }
if(mb_type&MB_TYPE_INTER4V){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_8X8;
@@ -3507,9 +3756,12 @@ static void encode_picture(MpegEncContext *s, int picture_number)
s->mv[0][0][1] = 0;
encode_mb_hq(s, &backup_s, &best_s, MB_TYPE_INTRA, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
- /* force cleaning of ac/dc pred stuff if needed ... */
- if(s->h263_pred || s->h263_aic)
- s->mbintra_table[mb_x + mb_y*s->mb_stride]=1;
+ if(s->h263_pred || s->h263_aic){
+ if(best_s.mb_intra)
+ s->mbintra_table[mb_x + mb_y*s->mb_stride]=1;
+ else
+ ff_clean_intra_table_entries(s); //old mode?
+ }
}
copy_context_after_encode(s, &best_s, -1);
@@ -3530,12 +3782,26 @@ static void encode_picture(MpegEncContext *s, int picture_number)
s->tex_pb= backup_s.tex_pb;
}
s->last_bits= get_bit_count(&s->pb);
+
+#ifdef CONFIG_RISKY
+ if (s->out_format == FMT_H263 && s->pict_type!=B_TYPE)
+ ff_h263_update_motion_val(s);
+#endif
+
+ if(next_block==0){
+ s->dsp.put_pixels_tab[0][0](s->dest[0], s->me.scratchpad , s->linesize ,16);
+ s->dsp.put_pixels_tab[1][0](s->dest[1], s->me.scratchpad + 16, s->uvlinesize, 8);
+ s->dsp.put_pixels_tab[1][0](s->dest[2], s->me.scratchpad + 24, s->uvlinesize, 8);
+ }
+
+ if(s->avctx->mb_decision == FF_MB_DECISION_BITS)
+ MPV_decode_mb(s, s->block);
} else {
int motion_x, motion_y;
int intra_score;
int inter_score= s->current_picture.mb_cmp_score[mb_x + mb_y*s->mb_stride];
- if(!(s->flags&CODEC_FLAG_HQ) && s->pict_type==P_TYPE){
+ if(s->avctx->mb_decision==FF_MB_DECISION_SIMPLE && s->pict_type==P_TYPE){ //FIXME check if the mess is usefull at all
/* get luma score */
if((s->avctx->mb_cmp&0xFF)==FF_CMP_SSE){
intra_score= (s->current_picture.mb_var[mb_x + mb_y*s->mb_stride]<<8) - 500; //FIXME dont scale it down so we dont have to fix it
@@ -3683,6 +3949,13 @@ static void encode_picture(MpegEncContext *s, int picture_number)
// RAL: Update last macrobloc type
s->last_mv_dir = s->mv_dir;
+
+#ifdef CONFIG_RISKY
+ if (s->out_format == FMT_H263 && s->pict_type!=B_TYPE)
+ ff_h263_update_motion_val(s);
+#endif
+
+ MPV_decode_mb(s, s->block);
}
/* clean the MV table in IPS frames for direct mode in B frames */
@@ -3690,8 +3963,6 @@ static void encode_picture(MpegEncContext *s, int picture_number)
s->p_mv_table[xy][0]=0;
s->p_mv_table[xy][1]=0;
}
-
- MPV_decode_mb(s, s->block);
if(s->flags&CODEC_FLAG_PSNR){
int w= 16;
@@ -3701,20 +3972,14 @@ static void encode_picture(MpegEncContext *s, int picture_number)
if(s->mb_y*16 + 16 > s->height) h= s->height- s->mb_y*16;
s->current_picture_ptr->error[0] += sse(
- s,
- s->new_picture .data[0] + s->mb_x*16 + s->mb_y*s->linesize*16,
- s->current_picture.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16,
- w, h, s->linesize);
+ s, s->new_picture.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16,
+ s->dest[0], w, h, s->linesize);
s->current_picture_ptr->error[1] += sse(
- s,
- s->new_picture .data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,
- s->current_picture.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,
- w>>1, h>>1, s->uvlinesize);
+ s, s->new_picture.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,
+ s->dest[1], w>>1, h>>1, s->uvlinesize);
s->current_picture_ptr->error[2] += sse(
- s,
- s->new_picture .data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,
- s->current_picture.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,
- w>>1, h>>1, s->uvlinesize);
+ s, s->new_picture .data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,
+ s->dest[2], w>>1, h>>1, s->uvlinesize);
}
//printf("MB %d %d bits\n", s->mb_x+s->mb_y*s->mb_stride, get_bit_count(&s->pb));
}
@@ -3762,14 +4027,17 @@ static int dct_quantize_trellis_c(MpegEncContext *s,
int last_level=0;
int last_score= 0;
int last_i= 0;
+ int not_coded_score= 0;
int coeff[3][64];
int coeff_count[64];
- int lambda, qmul, qadd, start_i, last_non_zero, i;
+ int qmul, qadd, start_i, last_non_zero, i, dc;
const int esc_length= s->ac_esc_length;
uint8_t * length;
uint8_t * last_length;
int score_limit=0;
int left_limit= 0;
+ const int lambda= s->lambda2 >> (FF_LAMBDA_SHIFT - 6);
+ const int patch_table= s->out_format == FMT_MPEG1 && !s->mb_intra;
s->dsp.fdct (block);
@@ -3795,7 +4063,7 @@ static int dct_quantize_trellis_c(MpegEncContext *s,
start_i = 1;
last_non_zero = 0;
qmat = s->q_intra_matrix[qscale];
- if(s->mpeg_quant || s->codec_id== CODEC_ID_MPEG1VIDEO)
+ if(s->mpeg_quant || s->out_format == FMT_MPEG1)
bias= 1<<(QMAT_SHIFT-1);
length = s->intra_ac_vlc_length;
last_length= s->intra_ac_vlc_last_length;
@@ -3831,6 +4099,7 @@ static int dct_quantize_trellis_c(MpegEncContext *s,
// coeff[2][k]= -level+2;
}
coeff_count[k]= FFMIN(level, 2);
+ assert(coeff_count[k]);
max |=level;
last_non_zero = i;
}else{
@@ -3846,9 +4115,13 @@ static int dct_quantize_trellis_c(MpegEncContext *s,
return last_non_zero;
}
- lambda= (qscale*qscale*64*105 + 64)>>7; //FIXME finetune
-
score_tab[0]= 0;
+
+ if(patch_table){
+// length[UNI_AC_ENC_INDEX(0, 63)]=
+// length[UNI_AC_ENC_INDEX(0, 65)]= 2;
+ }
+
for(i=0; i<=last_non_zero - start_i; i++){
int level_index, run, j;
const int dct_coeff= block[ scantable[i + start_i] ];
@@ -3856,6 +4129,7 @@ static int dct_quantize_trellis_c(MpegEncContext *s,
int best_score=256*256*256*120;
last_score += zero_distoration;
+ not_coded_score += zero_distoration;
for(level_index=0; level_index < coeff_count[i]; level_index++){
int distoration;
int level= coeff[level_index][i];
@@ -3954,10 +4228,13 @@ static int dct_quantize_trellis_c(MpegEncContext *s,
//Note: there is a vlc code in mpeg4 which is 1 bit shorter then another one with a shorter run and the same level
while(score_tab[ left_limit ] > score_limit + lambda) left_limit++;
+
+ if(patch_table){
+// length[UNI_AC_ENC_INDEX(0, 63)]=
+// length[UNI_AC_ENC_INDEX(0, 65)]= 3;
+ }
}
- //FIXME add some cbp penalty
-
if(s->out_format != FMT_H263){
last_score= 256*256*256*120;
for(i= left_limit; i<=last_non_zero - start_i + 1; i++){
@@ -3972,13 +4249,60 @@ static int dct_quantize_trellis_c(MpegEncContext *s,
}
}
}
+
+ s->coded_score[n] = last_score - not_coded_score;
+ dc= block[0];
last_non_zero= last_i - 1 + start_i;
memset(block + start_i, 0, (64-start_i)*sizeof(DCTELEM));
if(last_non_zero < start_i)
return last_non_zero;
-
+
+ if(last_non_zero == 0 && start_i == 0){
+ int best_level= 0;
+ int best_score= dc * dc;
+
+ for(i=0; i<coeff_count[0]; i++){
+ int level= coeff[i][0];
+ int unquant_coeff, score, distoration;
+
+ if(s->out_format == FMT_H263){
+ if(level>0){
+ unquant_coeff= (level*qmul + qadd)>>3;
+ }else{
+ unquant_coeff= (level*qmul - qadd)>>3;
+ }
+ }else{ //MPEG1
+ if (level < 0) {
+ unquant_coeff = ((((-level) << 1) + 1) * qscale * ((int) s->inter_matrix[0])) >> 4;
+ unquant_coeff = -((unquant_coeff - 1) | 1);
+ } else {
+ unquant_coeff = ((( level << 1) + 1) * qscale * ((int) s->inter_matrix[0])) >> 4;
+ unquant_coeff = (unquant_coeff - 1) | 1;
+ }
+ }
+ unquant_coeff = (unquant_coeff + 4) >> 3;
+ unquant_coeff<<= 3 + 3;
+
+ distoration= (unquant_coeff - dc) * (unquant_coeff - dc);
+ level+=64;
+ if((level&(~127)) == 0)
+ score= distoration + last_length[UNI_AC_ENC_INDEX(0, level)]*lambda;
+ else
+ score= distoration + esc_length*lambda;
+
+ if(score < best_score){
+ best_score= score;
+ best_level= level - 64;
+ }
+ }
+ block[0]= best_level;
+ s->coded_score[n] = best_score - dc*dc;
+ if(best_level == 0) return -1;
+ else return last_non_zero;
+ }
+
i= last_i;
assert(last_level);
//FIXME use permutated scantable
@@ -4239,7 +4563,6 @@ static void dct_unquantize_h263_c(MpegEncContext *s,
static const AVOption mpeg4_options[] =
{
AVOPTION_CODEC_INT("bitrate", "desired video bitrate", bit_rate, 4, 240000000, 800000),
- AVOPTION_CODEC_FLAG("vhq", "very high quality", flags, CODEC_FLAG_HQ, 0),
AVOPTION_CODEC_INT("ratetol", "number of bits the bitstream is allowed to diverge from the reference"
"the reference can be CBR (for CBR pass1) or VBR (for pass2)",
bit_rate_tolerance, 4, 240000000, 8000),
@@ -4325,6 +4648,16 @@ AVCodec mpeg1video_encoder = {
#ifdef CONFIG_RISKY
+AVCodec mpeg2video_encoder = {
+ "mpeg2video",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_MPEG2VIDEO,
+ sizeof(MpegEncContext),
+ MPV_encode_init,
+ MPV_encode_picture,
+ MPV_encode_end,
+};
+
AVCodec h263_encoder = {
"h263",
CODEC_TYPE_VIDEO,
@@ -4345,6 +4678,16 @@ AVCodec h263p_encoder = {
MPV_encode_end,
};
+AVCodec flv_encoder = {
+ "flv",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_FLV1,
+ sizeof(MpegEncContext),
+ MPV_encode_init,
+ MPV_encode_picture,
+ MPV_encode_end,
+};
+
AVCodec rv10_encoder = {
"rv10",
CODEC_TYPE_VIDEO,
diff --git a/src/libffmpeg/libavcodec/mpegvideo.h b/src/libffmpeg/libavcodec/mpegvideo.h
index 5f3c10d24..30432c173 100644
--- a/src/libffmpeg/libavcodec/mpegvideo.h
+++ b/src/libffmpeg/libavcodec/mpegvideo.h
@@ -269,6 +269,7 @@ typedef struct MpegEncContext {
int h263_rv10; ///< use RV10 variation for H263
int h263_msmpeg4; ///< generate MSMPEG4 compatible stream (deprecated, use msmpeg4_version instead)
int h263_intel; ///< use I263 intel h263 header
+ int h263_flv; ///< use flv h263 header
int codec_id; /* see CODEC_ID_xxx */
int fixed_qscale; ///< fixed qscale if non zero
@@ -330,7 +331,6 @@ typedef struct MpegEncContext {
Picture *last_picture_ptr; ///< pointer to the previous picture.
Picture *next_picture_ptr; ///< pointer to the next picture (for bidir pred)
- Picture *new_picture_ptr; ///< pointer to the source picture for encoding
Picture *current_picture_ptr; ///< pointer to the current picture
int last_dc[3]; ///< last DC values for MPEG1
int16_t *dc_val[3]; ///< used for mpeg4 DC prediction, all 3 arrays must be continuous
@@ -353,7 +353,9 @@ typedef struct MpegEncContext {
uint8_t *edge_emu_buffer; ///< points into the middle of allocated_edge_emu_buffer
int qscale; ///< QP
- float frame_qscale; ///< qscale from the frame level rc FIXME remove
+ int lambda; ///< lagrange multipler used in rate distortion
+ int lambda2; ///< (lambda*lambda) >> FF_LAMBDA_SHIFT
+ int *lambda_table;
int adaptive_quant; ///< use adaptive quantization
int dquant; ///< qscale difference to prev qscale
int pict_type; ///< I_TYPE, P_TYPE, B_TYPE, ...
@@ -429,6 +431,7 @@ typedef struct MpegEncContext {
int block_index[6]; ///< index to current MB in block based arrays with edges
int block_wrap[6];
+ uint8_t *dest[3];
int *mb_index2xy; ///< mb_index -> mb_x + mb_y*mb_stride
@@ -451,6 +454,8 @@ typedef struct MpegEncContext {
uint8_t *chroma_dc_vlc_length;
#define UNI_AC_ENC_INDEX(run,level) ((run)*128 + (level))
+ int coded_score[6];
+
/** precomputed matrix (combine qscale and DCT renorm) */
int __align8 q_intra_matrix[32][64];
int __align8 q_inter_matrix[32][64];
@@ -549,8 +554,6 @@ typedef struct MpegEncContext {
int new_pred;
int reduced_res_vop;
int aspect_ratio_info; //FIXME remove
- int aspected_width; //FIXME remove
- int aspected_height; //FIXME remove
int sprite_warping_accuracy;
int low_latency_sprite;
int data_partitioning; ///< data partitioning flag from header
@@ -560,6 +563,7 @@ typedef struct MpegEncContext {
int low_delay; ///< no reordering needed / has no b-frames
int vo_type;
int vol_control_parameters; ///< does the stream contain the low_delay flag, used to workaround buggy encoders
+ int intra_dc_threshold; ///< QP above whch the ac VLC should be used for intra dc
PutBitContext tex_pb; ///< used for data partitioned VOPs
PutBitContext pb2; ///< used for data partitioned VOPs
#define PB_BUFFER_SIZE 1024*256
@@ -642,11 +646,10 @@ typedef struct MpegEncContext {
int repeat_first_field;
int chroma_420_type;
int progressive_frame;
- int mpeg2;
int full_pel[2];
int interlaced_dct;
int first_slice;
- int first_field;
+ int first_field; ///< is 1 for the first field of a field picture 0 otherwise
/* RTP specific */
/* These are explained on avcodec.h */
@@ -660,8 +663,8 @@ typedef struct MpegEncContext {
int (*decode_mb)(struct MpegEncContext *s, DCTELEM block[6][64]); // used by some codecs to avoid a switch()
#define SLICE_OK 0
#define SLICE_ERROR -1
-#define SLICE_END -2 //end marker found
-#define SLICE_NOEND -3 //no end marker or error found but mb count exceeded
+#define SLICE_END -2 ///<end marker found
+#define SLICE_NOEND -3 ///<no end marker or error found but mb count exceeded
void (*dct_unquantize_mpeg1)(struct MpegEncContext *s,
DCTELEM *block/*align 16*/, int n, int qscale);
@@ -712,7 +715,9 @@ void ff_emulated_edge_mc(uint8_t *buf, uint8_t *src, int linesize, int block_w,
int src_x, int src_y, int w, int h);
#define END_NOT_FOUND -100
int ff_combine_frame( MpegEncContext *s, int next, uint8_t **buf, int *buf_size);
+void ff_mpeg_flush(AVCodecContext *avctx);
void ff_print_debug_info(MpegEncContext *s, Picture *pict);
+void ff_write_quant_matrix(PutBitContext *pb, int16_t *matrix);
void ff_er_frame_start(MpegEncContext *s);
void ff_er_frame_end(MpegEncContext *s);
@@ -721,14 +726,7 @@ void ff_er_add_slice(MpegEncContext *s, int startx, int starty, int endx, int en
extern enum PixelFormat ff_yuv420p_list[2];
-static inline void ff_init_block_index(MpegEncContext *s){
- s->block_index[0]= s->block_wrap[0]*(s->mb_y*2 + 1) - 1 + s->mb_x*2;
- s->block_index[1]= s->block_wrap[0]*(s->mb_y*2 + 1) + s->mb_x*2;
- s->block_index[2]= s->block_wrap[0]*(s->mb_y*2 + 2) - 1 + s->mb_x*2;
- s->block_index[3]= s->block_wrap[0]*(s->mb_y*2 + 2) + s->mb_x*2;
- s->block_index[4]= s->block_wrap[4]*(s->mb_y + 1) + s->block_wrap[0]*(s->mb_height*2 + 2) + s->mb_x;
- s->block_index[5]= s->block_wrap[4]*(s->mb_y + 1 + s->mb_height + 2) + s->block_wrap[0]*(s->mb_height*2 + 2) + s->mb_x;
-}
+void ff_init_block_index(MpegEncContext *s);
static inline void ff_update_block_index(MpegEncContext *s){
s->block_index[0]+=2;
@@ -737,6 +735,9 @@ static inline void ff_update_block_index(MpegEncContext *s){
s->block_index[3]+=2;
s->block_index[4]++;
s->block_index[5]++;
+ s->dest[0]+= 16;
+ s->dest[1]+= 8;
+ s->dest[2]+= 8;
}
static inline int get_bits_diff(MpegEncContext *s){
@@ -818,6 +819,7 @@ void mpeg4_encode_mb(MpegEncContext *s,
DCTELEM block[6][64],
int motion_x, int motion_y);
void h263_encode_picture_header(MpegEncContext *s, int picture_number);
+void ff_flv_encode_picture_header(MpegEncContext *s, int picture_number);
int h263_encode_gob_header(MpegEncContext * s, int mb_line);
int16_t *h263_pred_motion(MpegEncContext * s, int block,
int *px, int *py);
@@ -830,9 +832,11 @@ void h263_decode_init_vlc(MpegEncContext *s);
int h263_decode_picture_header(MpegEncContext *s);
int ff_h263_decode_gob_header(MpegEncContext *s);
int ff_mpeg4_decode_picture_header(MpegEncContext * s, GetBitContext *gb);
+void ff_h263_update_motion_val(MpegEncContext * s);
int intel_h263_decode_picture_header(MpegEncContext *s);
+int flv_h263_decode_picture_header(MpegEncContext *s);
int ff_h263_decode_mb(MpegEncContext *s,
DCTELEM block[6][64]);
int h263_get_picture_format(int width, int height);
@@ -867,6 +871,7 @@ int msmpeg4_decode_ext_header(MpegEncContext * s, int buf_size);
int ff_msmpeg4_decode_init(MpegEncContext *s);
void ff_msmpeg4_encode_init(MpegEncContext *s);
int ff_wmv2_decode_picture_header(MpegEncContext * s);
+int ff_wmv2_decode_secondary_picture_header(MpegEncContext * s);
void ff_wmv2_add_mb(MpegEncContext *s, DCTELEM block[6][64], uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr);
void ff_mspel_motion(MpegEncContext *s,
uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
diff --git a/src/libffmpeg/libavcodec/msmpeg4.c b/src/libffmpeg/libavcodec/msmpeg4.c
index 72481e325..d62c572cb 100644
--- a/src/libffmpeg/libavcodec/msmpeg4.c
+++ b/src/libffmpeg/libavcodec/msmpeg4.c
@@ -58,17 +58,13 @@
static uint32_t v2_dc_lum_table[512][2];
static uint32_t v2_dc_chroma_table[512][2];
-#ifdef CONFIG_ENCODERS
static inline void msmpeg4_encode_block(MpegEncContext * s, DCTELEM * block, int n);
-#endif //CONFIG_ENCODERS
static inline int msmpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
int n, int coded, const uint8_t *scantable);
static int msmpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr);
static int msmpeg4_decode_motion(MpegEncContext * s,
int *mx_ptr, int *my_ptr);
-#ifdef CONFIG_ENCODERS
static void msmpeg4v2_encode_motion(MpegEncContext * s, int val);
-#endif //CONFIG_ENCODERS
static void init_h263_dc_for_msmpeg4(void);
static inline void msmpeg4_memsetw(short *tab, int val, int n);
#ifdef CONFIG_ENCODERS
@@ -86,7 +82,9 @@ int frame_count = 0;
#include "msmpeg4data.h"
+#ifdef CONFIG_ENCODERS //strangely gcc includes this even if its not references
static uint8_t rl_length[NB_RL_TABLES][MAX_LEVEL+1][MAX_RUN+1][2];
+#endif //CONFIG_ENCODERS
#ifdef STATS
@@ -850,8 +848,6 @@ static inline int msmpeg4_pred_dc(MpegEncContext * s, int n,
#define DC_MAX 119
-#ifdef CONFIG_ENCODERS
-
static void msmpeg4_encode_dc(MpegEncContext * s, int level, int n, int *dir_ptr)
{
int sign, code;
@@ -1044,8 +1040,6 @@ else
}
}
-#endif //CONFIG_ENCODERS
-
/****************************************/
/* decoding stuff */
@@ -1319,13 +1313,14 @@ return -1;
break;
}
s->no_rounding = 1;
-/* printf("qscale:%d rlc:%d rl:%d dc:%d mbrl:%d slice:%d \n",
+ if(s->avctx->debug&FF_DEBUG_PICT_INFO)
+ printf("qscale:%d rlc:%d rl:%d dc:%d mbrl:%d slice:%d \n",
s->qscale,
s->rl_chroma_table_index,
s->rl_table_index,
s->dc_table_index,
s->per_mb_rl_table,
- s->slice_height);*/
+ s->slice_height);
} else {
switch(s->msmpeg4_version){
case 1:
@@ -1365,14 +1360,17 @@ return -1;
s->inter_intra_pred= (s->width*s->height < 320*240 && s->bit_rate<=II_BITRATE);
break;
}
-/* printf("skip:%d rl:%d rlc:%d dc:%d mv:%d mbrl:%d qp:%d \n",
+
+ if(s->avctx->debug&FF_DEBUG_PICT_INFO)
+ printf("skip:%d rl:%d rlc:%d dc:%d mv:%d mbrl:%d qp:%d \n",
s->use_skip_mb_code,
s->rl_table_index,
s->rl_chroma_table_index,
s->dc_table_index,
s->mv_table_index,
s->per_mb_rl_table,
- s->qscale);*/
+ s->qscale);
+
if(s->flipflop_rounding){
s->no_rounding ^= 1;
}else{
@@ -1411,7 +1409,8 @@ int msmpeg4_decode_ext_header(MpegEncContext * s, int buf_size)
else if(left<length+8)
{
s->flipflop_rounding= 0;
- printf("ext header missing, %d left\n", left);
+ if(s->msmpeg4_version != 2)
+ printf("ext header missing, %d left\n", left);
}
else
{
@@ -1428,8 +1427,6 @@ static inline void msmpeg4_memsetw(short *tab, int val, int n)
tab[i] = val;
}
-#ifdef CONFIG_ENCODERS
-
static void msmpeg4v2_encode_motion(MpegEncContext * s, int val)
{
int range, bit_size, sign, code, bits;
@@ -1463,8 +1460,6 @@ static void msmpeg4v2_encode_motion(MpegEncContext * s, int val)
}
}
-#endif //CONFIG_ENCODERS
-
/* this is identical to h263 except that its range is multiplied by 2 */
static int msmpeg4v2_decode_motion(MpegEncContext * s, int pred, int f_code)
{
diff --git a/src/libffmpeg/libavcodec/msrle.c b/src/libffmpeg/libavcodec/msrle.c
new file mode 100644
index 000000000..8943ef3cd
--- /dev/null
+++ b/src/libffmpeg/libavcodec/msrle.c
@@ -0,0 +1,219 @@
+/*
+ * Micrsoft RLE Video Decoder
+ * 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
+ */
+
+/**
+ * @file msrle.c
+ * MS RLE Video Decoder by Mike Melanson (melanson@pcisys.net)
+ * For more information about the MS RLE format, visit:
+ * http://www.pcisys.net/~melanson/codecs/
+ *
+ * The MS RLE decoder outputs PAL8 colorspace data.
+ *
+ * Note that this decoder expects the palette colors from the end of the
+ * BITMAPINFO header passed through extradata.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "common.h"
+#include "avcodec.h"
+#include "dsputil.h"
+
+typedef struct MsrleContext {
+ AVCodecContext *avctx;
+ AVFrame frame;
+ AVFrame prev_frame;
+
+ unsigned char *buf;
+ int size;
+
+ unsigned int palette[256];
+} MsrleContext;
+
+#define FETCH_NEXT_STREAM_BYTE() \
+ if (stream_ptr >= s->size) \
+ { \
+ printf(" MS RLE: stream ptr just went out of bounds (1)\n"); \
+ return; \
+ } \
+ stream_byte = s->buf[stream_ptr++];
+
+static void msrle_decode_pal8(MsrleContext *s)
+{
+ int stream_ptr = 0;
+ unsigned char rle_code;
+ unsigned char extra_byte;
+ unsigned char stream_byte;
+ int pixel_ptr = 0;
+ int row_dec = s->frame.linesize[0];
+ int row_ptr = (s->avctx->height - 1) * row_dec;
+ int frame_size = row_dec * s->avctx->height;
+
+ while (row_ptr >= 0) {
+ FETCH_NEXT_STREAM_BYTE();
+ rle_code = stream_byte;
+ if (rle_code == 0) {
+ /* fetch the next byte to see how to handle escape code */
+ FETCH_NEXT_STREAM_BYTE();
+ if (stream_byte == 0) {
+ /* line is done, goto the next one */
+ row_ptr -= row_dec;
+ pixel_ptr = 0;
+ } else if (stream_byte == 1) {
+ /* decode is done */
+ return;
+ } else if (stream_byte == 2) {
+ /* reposition frame decode coordinates */
+ FETCH_NEXT_STREAM_BYTE();
+ pixel_ptr += stream_byte;
+ FETCH_NEXT_STREAM_BYTE();
+ row_ptr -= stream_byte * row_dec;
+ } else {
+ /* copy pixels from encoded stream */
+ if ((row_ptr + pixel_ptr + stream_byte > frame_size) ||
+ (row_ptr < 0)) {
+ printf(" MS RLE: frame ptr just went out of bounds (1)\n");
+ return;
+ }
+
+ rle_code = stream_byte;
+ extra_byte = stream_byte & 0x01;
+ if (stream_ptr + rle_code + extra_byte > s->size) {
+ printf(" MS RLE: stream ptr just went out of bounds (2)\n");
+ return;
+ }
+
+ while (rle_code--) {
+ FETCH_NEXT_STREAM_BYTE();
+ s->frame.data[0][row_ptr + pixel_ptr] = stream_byte;
+ pixel_ptr++;
+ }
+
+ /* if the RLE code is odd, skip a byte in the stream */
+ if (extra_byte)
+ stream_ptr++;
+ }
+ } else {
+ /* decode a run of data */
+ if ((row_ptr + pixel_ptr + stream_byte > frame_size) ||
+ (row_ptr < 0)) {
+ printf(" MS RLE: frame ptr just went out of bounds (2)\n");
+ return;
+ }
+
+ FETCH_NEXT_STREAM_BYTE();
+
+ while(rle_code--) {
+ s->frame.data[0][row_ptr + pixel_ptr] = stream_byte;
+ pixel_ptr++;
+ }
+ }
+ }
+
+ /* make the palette available */
+ memcpy(s->frame.data[1], s->palette, 256 * 4);
+
+ /* one last sanity check on the way out */
+ if (stream_ptr < s->size)
+ printf(" MS RLE: ended frame decode with bytes left over (%d < %d)\n",
+ stream_ptr, s->size);
+}
+
+static int msrle_decode_init(AVCodecContext *avctx)
+{
+ MsrleContext *s = (MsrleContext *)avctx->priv_data;
+ int i, j;
+ unsigned char *palette;
+
+ s->avctx = avctx;
+
+ avctx->pix_fmt = PIX_FMT_PAL8;
+ avctx->has_b_frames = 0;
+ s->frame.data[0] = s->prev_frame.data[0] = NULL;
+
+ /* convert palette */
+ palette = (unsigned char *)s->avctx->extradata;
+ memset (s->palette, 0, 256 * 4);
+ for (i = 0, j = 0; i < s->avctx->extradata_size / 4; i++, j += 4)
+ s->palette[i] =
+ (palette[j + 2] << 16) |
+ (palette[j + 1] << 8) |
+ (palette[j + 0] << 0);
+
+ return 0;
+}
+
+static int msrle_decode_frame(AVCodecContext *avctx,
+ void *data, int *data_size,
+ uint8_t *buf, int buf_size)
+{
+ MsrleContext *s = (MsrleContext *)avctx->priv_data;
+
+ s->buf = buf;
+ s->size = buf_size;
+
+ if (avctx->get_buffer(avctx, &s->frame)) {
+ printf (" MS RLE: get_buffer() failed\n");
+ return -1;
+ }
+
+ /* grossly inefficient, but...oh well */
+ memcpy(s->frame.data[0], s->prev_frame.data[0],
+ s->frame.linesize[0] * s->avctx->height);
+
+ msrle_decode_pal8(s);
+
+ if (s->frame.data[0])
+ avctx->release_buffer(avctx, &s->frame);
+
+ /* shuffle frames */
+ s->prev_frame = s->frame;
+
+ *data_size = sizeof(AVFrame);
+ *(AVFrame*)data = s->frame;
+
+ /* report that the buffer was completely consumed */
+ return buf_size;
+}
+
+static int msrle_decode_end(AVCodecContext *avctx)
+{
+ MsrleContext *s = (MsrleContext *)avctx->priv_data;
+
+ /* release the last frame */
+ if (s->prev_frame.data[0])
+ avctx->release_buffer(avctx, &s->prev_frame);
+
+ return 0;
+}
+
+AVCodec msrle_decoder = {
+ "msrle",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_MSRLE,
+ sizeof(MsrleContext),
+ msrle_decode_init,
+ NULL,
+ msrle_decode_end,
+ msrle_decode_frame,
+ CODEC_CAP_DR1,
+};
diff --git a/src/libffmpeg/libavcodec/msvideo1.c b/src/libffmpeg/libavcodec/msvideo1.c
new file mode 100644
index 000000000..71d8af987
--- /dev/null
+++ b/src/libffmpeg/libavcodec/msvideo1.c
@@ -0,0 +1,378 @@
+/*
+ * Microsoft Video-1 Decoder
+ * 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
+ *
+ */
+
+/**
+ * @file msvideo1.c
+ * Microsoft Video-1 Decoder by Mike Melanson (melanson@pcisys.net)
+ * For more information about the MS Video-1 format, visit:
+ * http://www.pcisys.net/~melanson/codecs/
+ *
+ * This decoder outputs either PAL8 or RGB555 data, depending on the
+ * whether a RGB palette was passed through via extradata; if the extradata
+ * is present, then the data is PAL8; RGB555 otherwise.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "common.h"
+#include "avcodec.h"
+#include "dsputil.h"
+
+#define PALETTE_COUNT 256
+#define LE_16(x) ((((uint8_t*)(x))[1] << 8) | ((uint8_t*)(x))[0])
+#define CHECK_STREAM_PTR(n) \
+ if ((stream_ptr + n) > s->size ) { \
+ printf (" MS Video-1 warning: stream_ptr out of bounds (%d >= %d)\n", \
+ stream_ptr + n, s->size); \
+ return; \
+ }
+
+#define COPY_PREV_BLOCK() \
+ pixel_ptr = block_ptr; \
+ for (pixel_y = 0; pixel_y < 4; pixel_y++) { \
+ for (pixel_x = 0; pixel_x < 4; pixel_x++, pixel_ptr++) \
+ pixels[pixel_ptr] = prev_pixels[pixel_ptr]; \
+ pixel_ptr -= row_dec; \
+ }
+
+typedef struct Msvideo1Context {
+
+ AVCodecContext *avctx;
+ DSPContext dsp;
+ AVFrame frame;
+ AVFrame prev_frame;
+
+ unsigned char *buf;
+ int size;
+
+ int mode_8bit; /* if it's not 8-bit, it's 16-bit */
+ unsigned char palette[PALETTE_COUNT * 4];
+
+} Msvideo1Context;
+
+static int msvideo1_decode_init(AVCodecContext *avctx)
+{
+ Msvideo1Context *s = (Msvideo1Context *)avctx->priv_data;
+ int i;
+ unsigned char r, g, b;
+ unsigned char *raw_palette;
+ unsigned int *palette32;
+
+ s->avctx = avctx;
+
+ /* figure out the colorspace based on the presence of a palette in
+ * extradata */
+ if (s->avctx->extradata_size) {
+ s->mode_8bit = 1;
+ /* load up the palette */
+ palette32 = (unsigned int *)s->palette;
+ raw_palette = (unsigned char *)s->avctx->extradata;
+ for (i = 0; i < s->avctx->extradata_size / 4; i++) {
+ b = *raw_palette++;
+ g = *raw_palette++;
+ r = *raw_palette++;
+ raw_palette++;
+ palette32[i] = (r << 16) | (g << 8) | (b);
+ }
+ avctx->pix_fmt = PIX_FMT_PAL8;
+ } else {
+ s->mode_8bit = 0;
+ avctx->pix_fmt = PIX_FMT_RGB555;
+ }
+
+ avctx->has_b_frames = 0;
+ dsputil_init(&s->dsp, avctx);
+
+ s->frame.data[0] = s->prev_frame.data[0] = NULL;
+
+ return 0;
+}
+
+static void msvideo1_decode_8bit(Msvideo1Context *s)
+{
+ int block_ptr, pixel_ptr;
+ int total_blocks;
+ int pixel_x, pixel_y; /* pixel width and height iterators */
+ int block_x, block_y; /* block width and height iterators */
+ int blocks_wide, blocks_high; /* width and height in 4x4 blocks */
+ int block_inc;
+ int row_dec;
+
+ /* decoding parameters */
+ int stream_ptr;
+ unsigned char byte_a, byte_b;
+ unsigned short flags;
+ int skip_blocks;
+ unsigned char colors[8];
+ unsigned char *pixels = s->frame.data[0];
+ unsigned char *prev_pixels = s->prev_frame.data[0];
+ int stride = s->frame.linesize[0];
+
+ stream_ptr = 0;
+ skip_blocks = 0;
+ blocks_wide = s->avctx->width / 4;
+ blocks_high = s->avctx->height / 4;
+ total_blocks = blocks_wide * blocks_high;
+ block_inc = 4;
+ row_dec = stride + 4;
+
+ for (block_y = blocks_high; block_y > 0; block_y--) {
+ block_ptr = ((block_y * 4) - 1) * stride;
+ for (block_x = blocks_wide; block_x > 0; block_x--) {
+ /* check if this block should be skipped */
+ if (skip_blocks) {
+ COPY_PREV_BLOCK();
+ block_ptr += block_inc;
+ skip_blocks--;
+ total_blocks--;
+ continue;
+ }
+
+ pixel_ptr = block_ptr;
+
+ /* get the next two bytes in the encoded data stream */
+ CHECK_STREAM_PTR(2);
+ byte_a = s->buf[stream_ptr++];
+ byte_b = s->buf[stream_ptr++];
+
+ /* check if the decode is finished */
+ if ((byte_a == 0) && (byte_b == 0) && (total_blocks == 0))
+ return;
+ else if ((byte_b & 0xFC) == 0x84) {
+ /* skip code, but don't count the current block */
+ skip_blocks = ((byte_b - 0x84) << 8) + byte_a - 1;
+ COPY_PREV_BLOCK();
+ } else if (byte_b < 0x80) {
+ /* 2-color encoding */
+ flags = (byte_b << 8) | byte_a;
+
+ CHECK_STREAM_PTR(2);
+ colors[0] = s->buf[stream_ptr++];
+ colors[1] = s->buf[stream_ptr++];
+
+ for (pixel_y = 0; pixel_y < 4; pixel_y++) {
+ for (pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1)
+ pixels[pixel_ptr++] = colors[(flags & 0x1) ^ 1];
+ pixel_ptr -= row_dec;
+ }
+ } else if (byte_b >= 0x90) {
+ /* 8-color encoding */
+ flags = (byte_b << 8) | byte_a;
+
+ CHECK_STREAM_PTR(8);
+ memcpy(colors, &s->buf[stream_ptr], 8);
+ stream_ptr += 8;
+
+ for (pixel_y = 0; pixel_y < 4; pixel_y++) {
+ for (pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1)
+ pixels[pixel_ptr++] =
+ colors[((pixel_y & 0x2) << 1) +
+ (pixel_x & 0x2) + ((flags & 0x1) ^ 1)];
+ pixel_ptr -= row_dec;
+ }
+ } else {
+ /* 1-color encoding */
+ colors[0] = byte_a;
+
+ for (pixel_y = 0; pixel_y < 4; pixel_y++) {
+ for (pixel_x = 0; pixel_x < 4; pixel_x++)
+ pixels[pixel_ptr++] = colors[0];
+ pixel_ptr -= row_dec;
+ }
+ }
+
+ block_ptr += block_inc;
+ total_blocks--;
+ }
+ }
+
+ /* make the palette available on the way out */
+ if (s->avctx->pix_fmt == PIX_FMT_PAL8)
+ memcpy(s->frame.data[1], s->palette, PALETTE_COUNT * 4);
+}
+
+static void msvideo1_decode_16bit(Msvideo1Context *s)
+{
+ int block_ptr, pixel_ptr;
+ int total_blocks;
+ int pixel_x, pixel_y; /* pixel width and height iterators */
+ int block_x, block_y; /* block width and height iterators */
+ int blocks_wide, blocks_high; /* width and height in 4x4 blocks */
+ int block_inc;
+ int row_dec;
+
+ /* decoding parameters */
+ int stream_ptr;
+ unsigned char byte_a, byte_b;
+ unsigned short flags;
+ int skip_blocks;
+ unsigned short colors[8];
+ unsigned short *pixels = (unsigned short *)s->frame.data[0];
+ unsigned short *prev_pixels = (unsigned short *)s->prev_frame.data[0];
+ int stride = s->frame.linesize[0] / 2;
+
+ stream_ptr = 0;
+ skip_blocks = 0;
+ blocks_wide = s->avctx->width / 4;
+ blocks_high = s->avctx->height / 4;
+ total_blocks = blocks_wide * blocks_high;
+ block_inc = 4;
+ row_dec = stride + 4;
+
+ for (block_y = blocks_high; block_y > 0; block_y--) {
+ block_ptr = ((block_y * 4) - 1) * stride;
+ for (block_x = blocks_wide; block_x > 0; block_x--) {
+ /* check if this block should be skipped */
+ if (skip_blocks) {
+ COPY_PREV_BLOCK();
+ block_ptr += block_inc;
+ skip_blocks--;
+ total_blocks--;
+ continue;
+ }
+
+ pixel_ptr = block_ptr;
+
+ /* get the next two bytes in the encoded data stream */
+ CHECK_STREAM_PTR(2);
+ byte_a = s->buf[stream_ptr++];
+ byte_b = s->buf[stream_ptr++];
+
+ /* check if the decode is finished */
+ if ((byte_a == 0) && (byte_b == 0) && (total_blocks == 0)) {
+ return;
+ } else if ((byte_b & 0xFC) == 0x84) {
+ /* skip code, but don't count the current block */
+ skip_blocks = ((byte_b - 0x84) << 8) + byte_a - 1;
+ COPY_PREV_BLOCK();
+ } else if (byte_b < 0x80) {
+ /* 2- or 8-color encoding modes */
+ flags = (byte_b << 8) | byte_a;
+
+ CHECK_STREAM_PTR(4);
+ colors[0] = LE_16(&s->buf[stream_ptr]);
+ stream_ptr += 2;
+ colors[1] = LE_16(&s->buf[stream_ptr]);
+ stream_ptr += 2;
+
+ if (colors[0] & 0x8000) {
+ /* 8-color encoding */
+ CHECK_STREAM_PTR(12);
+ colors[2] = LE_16(&s->buf[stream_ptr]);
+ stream_ptr += 2;
+ colors[3] = LE_16(&s->buf[stream_ptr]);
+ stream_ptr += 2;
+ colors[4] = LE_16(&s->buf[stream_ptr]);
+ stream_ptr += 2;
+ colors[5] = LE_16(&s->buf[stream_ptr]);
+ stream_ptr += 2;
+ colors[6] = LE_16(&s->buf[stream_ptr]);
+ stream_ptr += 2;
+ colors[7] = LE_16(&s->buf[stream_ptr]);
+ stream_ptr += 2;
+
+ for (pixel_y = 0; pixel_y < 4; pixel_y++) {
+ for (pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1)
+ pixels[pixel_ptr++] =
+ colors[((pixel_y & 0x2) << 1) +
+ (pixel_x & 0x2) + ((flags & 0x1) ^ 1)];
+ pixel_ptr -= row_dec;
+ }
+ } else {
+ /* 2-color encoding */
+ for (pixel_y = 0; pixel_y < 4; pixel_y++) {
+ for (pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1)
+ pixels[pixel_ptr++] = colors[(flags & 0x1) ^ 1];
+ pixel_ptr -= row_dec;
+ }
+ }
+ } else {
+ /* otherwise, it's a 1-color block */
+ colors[0] = (byte_b << 8) | byte_a;
+
+ for (pixel_y = 0; pixel_y < 4; pixel_y++) {
+ for (pixel_x = 0; pixel_x < 4; pixel_x++)
+ pixels[pixel_ptr++] = colors[0];
+ pixel_ptr -= row_dec;
+ }
+ }
+
+ block_ptr += block_inc;
+ total_blocks--;
+ }
+ }
+}
+
+static int msvideo1_decode_frame(AVCodecContext *avctx,
+ void *data, int *data_size,
+ uint8_t *buf, int buf_size)
+{
+ Msvideo1Context *s = (Msvideo1Context *)avctx->priv_data;
+
+ s->buf = buf;
+ s->size = buf_size;
+
+ if (avctx->get_buffer(avctx, &s->frame)) {
+ printf (" MS Video-1 Video: get_buffer() failed\n");
+ return -1;
+ }
+
+ if (s->mode_8bit)
+ msvideo1_decode_8bit(s);
+ else
+ msvideo1_decode_16bit(s);
+
+ if (s->prev_frame.data[0])
+ avctx->release_buffer(avctx, &s->prev_frame);
+
+ /* shuffle frames */
+ s->prev_frame = s->frame;
+
+ *data_size = sizeof(AVFrame);
+ *(AVFrame*)data = s->frame;
+
+ /* report that the buffer was completely consumed */
+ return buf_size;
+}
+
+static int msvideo1_decode_end(AVCodecContext *avctx)
+{
+ Msvideo1Context *s = (Msvideo1Context *)avctx->priv_data;
+
+ if (s->prev_frame.data[0])
+ avctx->release_buffer(avctx, &s->prev_frame);
+
+ return 0;
+}
+
+AVCodec msvideo1_decoder = {
+ "msvideo1",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_MSVIDEO1,
+ sizeof(Msvideo1Context),
+ msvideo1_decode_init,
+ NULL,
+ msvideo1_decode_end,
+ msvideo1_decode_frame,
+ CODEC_CAP_DR1,
+};
diff --git a/src/libffmpeg/libavcodec/opts.c b/src/libffmpeg/libavcodec/opts.c
index 44a213397..2ce459d75 100644
--- a/src/libffmpeg/libavcodec/opts.c
+++ b/src/libffmpeg/libavcodec/opts.c
@@ -11,7 +11,6 @@
*/
#include "avcodec.h"
-#include "os_support.h"
const AVOption avoptions_common[] = {
AVOPTION_CODEC_FLAG("bit_exact", "use only bit-exact stuff", flags, CODEC_FLAG_BITEXACT, 0),
@@ -40,15 +39,32 @@ const AVOption avoptions_workaround_bug[] = {
AVOPTION_END()
};
+/* avoid compatibility problems by redefining it */
+static int av_strcasecmp(const char *s1, const char *s2)
+{
+ signed char val;
+
+ for(;;) {
+ val = toupper(*s1) - toupper(*s2);
+ if (val != 0)
+ break;
+ if (*s1 != '\0')
+ break;
+ s1++;
+ s2++;
+ }
+ return val;
+}
+
static int parse_bool(const AVOption *c, char *s, int *var)
{
int b = 1; /* by default -on- when present */
if (s) {
- if (!strcasecmp(s, "off") || !strcasecmp(s, "false")
+ if (!av_strcasecmp(s, "off") || !av_strcasecmp(s, "false")
|| !strcmp(s, "0"))
b = 0;
- else if (!strcasecmp(s, "on") || !strcasecmp(s, "true")
+ else if (!av_strcasecmp(s, "on") || !av_strcasecmp(s, "true")
|| !strcmp(s, "1"))
b = 1;
else
diff --git a/src/libffmpeg/libavcodec/pcm.c b/src/libffmpeg/libavcodec/pcm.c
new file mode 100644
index 000000000..a6c0d343b
--- /dev/null
+++ b/src/libffmpeg/libavcodec/pcm.c
@@ -0,0 +1,375 @@
+/*
+ * PCM codecs
+ * Copyright (c) 2001 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
+ */
+
+/**
+ * @file pcm.c
+ * PCM codecs
+ */
+
+#include "avcodec.h"
+
+/* from g711.c by SUN microsystems (unrestricted use) */
+
+#define SIGN_BIT (0x80) /* Sign bit for a A-law byte. */
+#define QUANT_MASK (0xf) /* Quantization field mask. */
+#define NSEGS (8) /* Number of A-law segments. */
+#define SEG_SHIFT (4) /* Left shift for segment number. */
+#define SEG_MASK (0x70) /* Segment field mask. */
+
+#define BIAS (0x84) /* Bias for linear code. */
+
+/*
+ * alaw2linear() - Convert an A-law value to 16-bit linear PCM
+ *
+ */
+static int alaw2linear(unsigned char a_val)
+{
+ int t;
+ int seg;
+
+ a_val ^= 0x55;
+
+ t = a_val & QUANT_MASK;
+ seg = ((unsigned)a_val & SEG_MASK) >> SEG_SHIFT;
+ if(seg) t= (t + t + 1 + 32) << (seg + 2);
+ else t= (t + t + 1 ) << 3;
+
+ return ((a_val & SIGN_BIT) ? t : -t);
+}
+
+static int ulaw2linear(unsigned char u_val)
+{
+ int t;
+
+ /* Complement to obtain normal u-law value. */
+ u_val = ~u_val;
+
+ /*
+ * Extract and bias the quantization bits. Then
+ * shift up by the segment number and subtract out the bias.
+ */
+ t = ((u_val & QUANT_MASK) << 3) + BIAS;
+ t <<= ((unsigned)u_val & SEG_MASK) >> SEG_SHIFT;
+
+ return ((u_val & SIGN_BIT) ? (BIAS - t) : (t - BIAS));
+}
+
+/* 16384 entries per table */
+static uint8_t *linear_to_alaw = NULL;
+static int linear_to_alaw_ref = 0;
+
+static uint8_t *linear_to_ulaw = NULL;
+static int linear_to_ulaw_ref = 0;
+
+static void build_xlaw_table(uint8_t *linear_to_xlaw,
+ int (*xlaw2linear)(unsigned char),
+ int mask)
+{
+ int i, j, v, v1, v2;
+
+ j = 0;
+ for(i=0;i<128;i++) {
+ if (i != 127) {
+ v1 = xlaw2linear(i ^ mask);
+ v2 = xlaw2linear((i + 1) ^ mask);
+ v = (v1 + v2 + 4) >> 3;
+ } else {
+ v = 8192;
+ }
+ for(;j<v;j++) {
+ linear_to_xlaw[8192 + j] = (i ^ mask);
+ if (j > 0)
+ linear_to_xlaw[8192 - j] = (i ^ (mask ^ 0x80));
+ }
+ }
+ linear_to_xlaw[0] = linear_to_xlaw[1];
+}
+
+static int pcm_encode_init(AVCodecContext *avctx)
+{
+ avctx->frame_size = 1;
+ switch(avctx->codec->id) {
+ case CODEC_ID_PCM_ALAW:
+ if (linear_to_alaw_ref == 0) {
+ linear_to_alaw = av_malloc(16384);
+ if (!linear_to_alaw)
+ return -1;
+ build_xlaw_table(linear_to_alaw, alaw2linear, 0xd5);
+ }
+ linear_to_alaw_ref++;
+ break;
+ case CODEC_ID_PCM_MULAW:
+ if (linear_to_ulaw_ref == 0) {
+ linear_to_ulaw = av_malloc(16384);
+ if (!linear_to_ulaw)
+ return -1;
+ build_xlaw_table(linear_to_ulaw, ulaw2linear, 0xff);
+ }
+ linear_to_ulaw_ref++;
+ break;
+ default:
+ break;
+ }
+
+ avctx->coded_frame= avcodec_alloc_frame();
+ avctx->coded_frame->key_frame= 1;
+
+ return 0;
+}
+
+static int pcm_encode_close(AVCodecContext *avctx)
+{
+ av_freep(&avctx->coded_frame);
+
+ switch(avctx->codec->id) {
+ case CODEC_ID_PCM_ALAW:
+ if (--linear_to_alaw_ref == 0)
+ av_free(linear_to_alaw);
+ break;
+ case CODEC_ID_PCM_MULAW:
+ if (--linear_to_ulaw_ref == 0)
+ av_free(linear_to_ulaw);
+ break;
+ default:
+ /* nothing to free */
+ break;
+ }
+ return 0;
+}
+
+static int pcm_encode_frame(AVCodecContext *avctx,
+ unsigned char *frame, int buf_size, void *data)
+{
+ int n, sample_size, v;
+ short *samples;
+ unsigned char *dst;
+
+ switch(avctx->codec->id) {
+ case CODEC_ID_PCM_S16LE:
+ case CODEC_ID_PCM_S16BE:
+ case CODEC_ID_PCM_U16LE:
+ case CODEC_ID_PCM_U16BE:
+ sample_size = 2;
+ break;
+ default:
+ sample_size = 1;
+ break;
+ }
+ n = buf_size / sample_size;
+ samples = data;
+ dst = frame;
+
+ switch(avctx->codec->id) {
+ case CODEC_ID_PCM_S16LE:
+ for(;n>0;n--) {
+ v = *samples++;
+ dst[0] = v & 0xff;
+ dst[1] = v >> 8;
+ dst += 2;
+ }
+ break;
+ case CODEC_ID_PCM_S16BE:
+ for(;n>0;n--) {
+ v = *samples++;
+ dst[0] = v >> 8;
+ dst[1] = v;
+ dst += 2;
+ }
+ break;
+ case CODEC_ID_PCM_U16LE:
+ for(;n>0;n--) {
+ v = *samples++;
+ v += 0x8000;
+ dst[0] = v & 0xff;
+ dst[1] = v >> 8;
+ dst += 2;
+ }
+ break;
+ case CODEC_ID_PCM_U16BE:
+ for(;n>0;n--) {
+ v = *samples++;
+ v += 0x8000;
+ dst[0] = v >> 8;
+ dst[1] = v;
+ dst += 2;
+ }
+ break;
+ case CODEC_ID_PCM_S8:
+ for(;n>0;n--) {
+ v = *samples++;
+ dst[0] = v >> 8;
+ dst++;
+ }
+ break;
+ case CODEC_ID_PCM_U8:
+ for(;n>0;n--) {
+ v = *samples++;
+ dst[0] = (v >> 8) + 128;
+ dst++;
+ }
+ break;
+ case CODEC_ID_PCM_ALAW:
+ for(;n>0;n--) {
+ v = *samples++;
+ dst[0] = linear_to_alaw[(v + 32768) >> 2];
+ dst++;
+ }
+ break;
+ case CODEC_ID_PCM_MULAW:
+ for(;n>0;n--) {
+ v = *samples++;
+ dst[0] = linear_to_ulaw[(v + 32768) >> 2];
+ dst++;
+ }
+ break;
+ default:
+ return -1;
+ }
+ //avctx->frame_size = (dst - frame) / (sample_size * avctx->channels);
+
+ return dst - frame;
+}
+
+typedef struct PCMDecode {
+ short table[256];
+} PCMDecode;
+
+static int pcm_decode_init(AVCodecContext * avctx)
+{
+ PCMDecode *s = avctx->priv_data;
+ int i;
+
+ switch(avctx->codec->id) {
+ case CODEC_ID_PCM_ALAW:
+ for(i=0;i<256;i++)
+ s->table[i] = alaw2linear(i);
+ break;
+ case CODEC_ID_PCM_MULAW:
+ for(i=0;i<256;i++)
+ s->table[i] = ulaw2linear(i);
+ break;
+ default:
+ break;
+ }
+ return 0;
+}
+
+static int pcm_decode_frame(AVCodecContext *avctx,
+ void *data, int *data_size,
+ uint8_t *buf, int buf_size)
+{
+ PCMDecode *s = avctx->priv_data;
+ int n;
+ short *samples;
+ uint8_t *src;
+
+ samples = data;
+ src = buf;
+
+ switch(avctx->codec->id) {
+ case CODEC_ID_PCM_S16LE:
+ n = buf_size >> 1;
+ for(;n>0;n--) {
+ *samples++ = src[0] | (src[1] << 8);
+ src += 2;
+ }
+ break;
+ case CODEC_ID_PCM_S16BE:
+ n = buf_size >> 1;
+ for(;n>0;n--) {
+ *samples++ = (src[0] << 8) | src[1];
+ src += 2;
+ }
+ break;
+ case CODEC_ID_PCM_U16LE:
+ n = buf_size >> 1;
+ for(;n>0;n--) {
+ *samples++ = (src[0] | (src[1] << 8)) - 0x8000;
+ src += 2;
+ }
+ break;
+ case CODEC_ID_PCM_U16BE:
+ n = buf_size >> 1;
+ for(;n>0;n--) {
+ *samples++ = ((src[0] << 8) | src[1]) - 0x8000;
+ src += 2;
+ }
+ break;
+ case CODEC_ID_PCM_S8:
+ n = buf_size;
+ for(;n>0;n--) {
+ *samples++ = src[0] << 8;
+ src++;
+ }
+ break;
+ case CODEC_ID_PCM_U8:
+ n = buf_size;
+ for(;n>0;n--) {
+ *samples++ = ((int)src[0] - 128) << 8;
+ src++;
+ }
+ break;
+ case CODEC_ID_PCM_ALAW:
+ case CODEC_ID_PCM_MULAW:
+ n = buf_size;
+ for(;n>0;n--) {
+ *samples++ = s->table[src[0]];
+ src++;
+ }
+ break;
+ default:
+ *data_size = 0;
+ return -1;
+ }
+ *data_size = (uint8_t *)samples - (uint8_t *)data;
+ return src - buf;
+}
+
+#define PCM_CODEC(id, name) \
+AVCodec name ## _encoder = { \
+ #name, \
+ CODEC_TYPE_AUDIO, \
+ id, \
+ 0, \
+ pcm_encode_init, \
+ pcm_encode_frame, \
+ pcm_encode_close, \
+ NULL, \
+}; \
+AVCodec name ## _decoder = { \
+ #name, \
+ CODEC_TYPE_AUDIO, \
+ id, \
+ sizeof(PCMDecode), \
+ pcm_decode_init, \
+ NULL, \
+ NULL, \
+ pcm_decode_frame, \
+}
+
+PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
+PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
+PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
+PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
+PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
+PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
+PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
+PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
+
+#undef PCM_CODEC
diff --git a/src/libffmpeg/libavcodec/ppc/dsputil_altivec.c b/src/libffmpeg/libavcodec/ppc/dsputil_altivec.c
index 32e881b70..635480784 100644
--- a/src/libffmpeg/libavcodec/ppc/dsputil_altivec.c
+++ b/src/libffmpeg/libavcodec/ppc/dsputil_altivec.c
@@ -655,11 +655,11 @@ void add_bytes_altivec(uint8_t *dst, uint8_t *src, int w) {
/* next one assumes that ((line_size % 16) == 0) */
void put_pixels16_altivec(uint8_t *block, const uint8_t *pixels, int line_size, int h)
{
-POWERPC_TBL_DECLARE(altivec_put_pixels16_num, 1);
+POWERPC_PERF_DECLARE(altivec_put_pixels16_num, 1);
#ifdef ALTIVEC_USE_REFERENCE_C_CODE
int i;
-POWERPC_TBL_START_COUNT(altivec_put_pixels16_num, 1);
+POWERPC_PERF_START_COUNT(altivec_put_pixels16_num, 1);
for(i=0; i<h; i++) {
*((uint32_t*)(block )) = (((const struct unaligned_32 *) (pixels))->l);
@@ -670,15 +670,27 @@ POWERPC_TBL_START_COUNT(altivec_put_pixels16_num, 1);
block +=line_size;
}
-POWERPC_TBL_STOP_COUNT(altivec_put_pixels16_num, 1);
+POWERPC_PERF_STOP_COUNT(altivec_put_pixels16_num, 1);
#else /* ALTIVEC_USE_REFERENCE_C_CODE */
register vector unsigned char pixelsv1, pixelsv2;
+ register vector unsigned char pixelsv1B, pixelsv2B;
+ register vector unsigned char pixelsv1C, pixelsv2C;
+ register vector unsigned char pixelsv1D, pixelsv2D;
+
register vector unsigned char perm = vec_lvsl(0, pixels);
int i;
-
-POWERPC_TBL_START_COUNT(altivec_put_pixels16_num, 1);
-
+ register int line_size_2 = line_size << 1;
+ register int line_size_3 = line_size + line_size_2;
+ register int line_size_4 = line_size << 2;
+
+POWERPC_PERF_START_COUNT(altivec_put_pixels16_num, 1);
+// hand-unrolling the loop by 4 gains about 15%
+// mininum execution time goes from 74 to 60 cycles
+// it's faster than -funroll-loops, but using
+// -funroll-loops w/ this is bad - 74 cycles again.
+// all this is on a 7450, tuning for the 7450
+#if 0
for(i=0; i<h; i++) {
pixelsv1 = vec_ld(0, (unsigned char*)pixels);
pixelsv2 = vec_ld(16, (unsigned char*)pixels);
@@ -687,8 +699,29 @@ POWERPC_TBL_START_COUNT(altivec_put_pixels16_num, 1);
pixels+=line_size;
block +=line_size;
}
-
-POWERPC_TBL_STOP_COUNT(altivec_put_pixels16_num, 1);
+#else
+ for(i=0; i<h; i+=4) {
+ pixelsv1 = vec_ld(0, (unsigned char*)pixels);
+ pixelsv2 = vec_ld(16, (unsigned char*)pixels);
+ pixelsv1B = vec_ld(line_size, (unsigned char*)pixels);
+ pixelsv2B = vec_ld(16 + line_size, (unsigned char*)pixels);
+ pixelsv1C = vec_ld(line_size_2, (unsigned char*)pixels);
+ pixelsv2C = vec_ld(16 + line_size_2, (unsigned char*)pixels);
+ pixelsv1D = vec_ld(line_size_3, (unsigned char*)pixels);
+ pixelsv2D = vec_ld(16 + line_size_3, (unsigned char*)pixels);
+ vec_st(vec_perm(pixelsv1, pixelsv2, perm),
+ 0, (unsigned char*)block);
+ vec_st(vec_perm(pixelsv1B, pixelsv2B, perm),
+ line_size, (unsigned char*)block);
+ vec_st(vec_perm(pixelsv1C, pixelsv2C, perm),
+ line_size_2, (unsigned char*)block);
+ vec_st(vec_perm(pixelsv1D, pixelsv2D, perm),
+ line_size_3, (unsigned char*)block);
+ pixels+=line_size_4;
+ block +=line_size_4;
+ }
+#endif
+POWERPC_PERF_STOP_COUNT(altivec_put_pixels16_num, 1);
#endif /* ALTIVEC_USE_REFERENCE_C_CODE */
}
@@ -697,11 +730,11 @@ POWERPC_TBL_STOP_COUNT(altivec_put_pixels16_num, 1);
#define op_avg(a,b) a = ( ((a)|(b)) - ((((a)^(b))&0xFEFEFEFEUL)>>1) )
void avg_pixels16_altivec(uint8_t *block, const uint8_t *pixels, int line_size, int h)
{
-POWERPC_TBL_DECLARE(altivec_avg_pixels16_num, 1);
+POWERPC_PERF_DECLARE(altivec_avg_pixels16_num, 1);
#ifdef ALTIVEC_USE_REFERENCE_C_CODE
int i;
-POWERPC_TBL_START_COUNT(altivec_avg_pixels16_num, 1);
+POWERPC_PERF_START_COUNT(altivec_avg_pixels16_num, 1);
for(i=0; i<h; i++) {
op_avg(*((uint32_t*)(block)),(((const struct unaligned_32 *)(pixels))->l));
@@ -712,14 +745,14 @@ POWERPC_TBL_START_COUNT(altivec_avg_pixels16_num, 1);
block +=line_size;
}
-POWERPC_TBL_STOP_COUNT(altivec_avg_pixels16_num, 1);
+POWERPC_PERF_STOP_COUNT(altivec_avg_pixels16_num, 1);
#else /* ALTIVEC_USE_REFERENCE_C_CODE */
register vector unsigned char pixelsv1, pixelsv2, pixelsv, blockv;
register vector unsigned char perm = vec_lvsl(0, pixels);
int i;
-POWERPC_TBL_START_COUNT(altivec_avg_pixels16_num, 1);
+POWERPC_PERF_START_COUNT(altivec_avg_pixels16_num, 1);
for(i=0; i<h; i++) {
pixelsv1 = vec_ld(0, (unsigned char*)pixels);
@@ -732,7 +765,7 @@ POWERPC_TBL_START_COUNT(altivec_avg_pixels16_num, 1);
block +=line_size;
}
-POWERPC_TBL_STOP_COUNT(altivec_avg_pixels16_num, 1);
+POWERPC_PERF_STOP_COUNT(altivec_avg_pixels16_num, 1);
#endif /* ALTIVEC_USE_REFERENCE_C_CODE */
}
@@ -740,10 +773,10 @@ POWERPC_TBL_STOP_COUNT(altivec_avg_pixels16_num, 1);
/* next one assumes that ((line_size % 8) == 0) */
void avg_pixels8_altivec(uint8_t * block, const uint8_t * pixels, int line_size, int h)
{
-POWERPC_TBL_DECLARE(altivec_avg_pixels8_num, 1);
+POWERPC_PERF_DECLARE(altivec_avg_pixels8_num, 1);
#ifdef ALTIVEC_USE_REFERENCE_C_CODE
int i;
-POWERPC_TBL_START_COUNT(altivec_avg_pixels8_num, 1);
+POWERPC_PERF_START_COUNT(altivec_avg_pixels8_num, 1);
for (i = 0; i < h; i++) {
*((uint32_t *) (block)) =
(((*((uint32_t *) (block))) |
@@ -761,13 +794,13 @@ POWERPC_TBL_START_COUNT(altivec_avg_pixels8_num, 1);
pixels += line_size;
block += line_size;
}
-POWERPC_TBL_STOP_COUNT(altivec_avg_pixels8_num, 1);
+POWERPC_PERF_STOP_COUNT(altivec_avg_pixels8_num, 1);
#else /* ALTIVEC_USE_REFERENCE_C_CODE */
register vector unsigned char pixelsv1, pixelsv2, pixelsv, blockv;
int i;
-POWERPC_TBL_START_COUNT(altivec_avg_pixels8_num, 1);
+POWERPC_PERF_START_COUNT(altivec_avg_pixels8_num, 1);
for (i = 0; i < h; i++) {
/*
@@ -798,7 +831,7 @@ POWERPC_TBL_START_COUNT(altivec_avg_pixels8_num, 1);
block += line_size;
}
-POWERPC_TBL_STOP_COUNT(altivec_avg_pixels8_num, 1);
+POWERPC_PERF_STOP_COUNT(altivec_avg_pixels8_num, 1);
#endif /* ALTIVEC_USE_REFERENCE_C_CODE */
}
@@ -806,10 +839,10 @@ POWERPC_TBL_STOP_COUNT(altivec_avg_pixels8_num, 1);
/* next one assumes that ((line_size % 8) == 0) */
void put_pixels8_xy2_altivec(uint8_t *block, const uint8_t *pixels, int line_size, int h)
{
-POWERPC_TBL_DECLARE(altivec_put_pixels8_xy2_num, 1);
+POWERPC_PERF_DECLARE(altivec_put_pixels8_xy2_num, 1);
#ifdef ALTIVEC_USE_REFERENCE_C_CODE
int j;
-POWERPC_TBL_START_COUNT(altivec_put_pixels8_xy2_num, 1);
+POWERPC_PERF_START_COUNT(altivec_put_pixels8_xy2_num, 1);
for (j = 0; j < 2; j++) {
int i;
const uint32_t a = (((const struct unaligned_32 *) (pixels))->l);
@@ -842,7 +875,7 @@ POWERPC_TBL_START_COUNT(altivec_put_pixels8_xy2_num, 1);
block += 4 - line_size * h;
}
-POWERPC_TBL_STOP_COUNT(altivec_put_pixels8_xy2_num, 1);
+POWERPC_PERF_STOP_COUNT(altivec_put_pixels8_xy2_num, 1);
#else /* ALTIVEC_USE_REFERENCE_C_CODE */
register int i;
@@ -873,7 +906,7 @@ POWERPC_TBL_STOP_COUNT(altivec_put_pixels8_xy2_num, 1);
(vector unsigned short)pixelsv2);
pixelssum1 = vec_add(pixelssum1, vctwo);
-POWERPC_TBL_START_COUNT(altivec_put_pixels8_xy2_num, 1);
+POWERPC_PERF_START_COUNT(altivec_put_pixels8_xy2_num, 1);
for (i = 0; i < h ; i++) {
int rightside = ((unsigned long)block & 0x0000000F);
blockv = vec_ld(0, block);
@@ -914,17 +947,17 @@ POWERPC_TBL_START_COUNT(altivec_put_pixels8_xy2_num, 1);
pixels += line_size;
}
-POWERPC_TBL_STOP_COUNT(altivec_put_pixels8_xy2_num, 1);
+POWERPC_PERF_STOP_COUNT(altivec_put_pixels8_xy2_num, 1);
#endif /* ALTIVEC_USE_REFERENCE_C_CODE */
}
/* next one assumes that ((line_size % 8) == 0) */
void put_no_rnd_pixels8_xy2_altivec(uint8_t *block, const uint8_t *pixels, int line_size, int h)
{
-POWERPC_TBL_DECLARE(altivec_put_no_rnd_pixels8_xy2_num, 1);
+POWERPC_PERF_DECLARE(altivec_put_no_rnd_pixels8_xy2_num, 1);
#ifdef ALTIVEC_USE_REFERENCE_C_CODE
int j;
-POWERPC_TBL_START_COUNT(altivec_put_no_rnd_pixels8_xy2_num, 1);
+POWERPC_PERF_START_COUNT(altivec_put_no_rnd_pixels8_xy2_num, 1);
for (j = 0; j < 2; j++) {
int i;
const uint32_t a = (((const struct unaligned_32 *) (pixels))->l);
@@ -957,7 +990,7 @@ POWERPC_TBL_START_COUNT(altivec_put_no_rnd_pixels8_xy2_num, 1);
block += 4 - line_size * h;
}
-POWERPC_TBL_STOP_COUNT(altivec_put_no_rnd_pixels8_xy2_num, 1);
+POWERPC_PERF_STOP_COUNT(altivec_put_no_rnd_pixels8_xy2_num, 1);
#else /* ALTIVEC_USE_REFERENCE_C_CODE */
register int i;
@@ -989,7 +1022,7 @@ POWERPC_TBL_STOP_COUNT(altivec_put_no_rnd_pixels8_xy2_num, 1);
(vector unsigned short)pixelsv2);
pixelssum1 = vec_add(pixelssum1, vcone);
-POWERPC_TBL_START_COUNT(altivec_put_no_rnd_pixels8_xy2_num, 1);
+POWERPC_PERF_START_COUNT(altivec_put_no_rnd_pixels8_xy2_num, 1);
for (i = 0; i < h ; i++) {
int rightside = ((unsigned long)block & 0x0000000F);
blockv = vec_ld(0, block);
@@ -1030,17 +1063,17 @@ POWERPC_TBL_START_COUNT(altivec_put_no_rnd_pixels8_xy2_num, 1);
pixels += line_size;
}
-POWERPC_TBL_STOP_COUNT(altivec_put_no_rnd_pixels8_xy2_num, 1);
+POWERPC_PERF_STOP_COUNT(altivec_put_no_rnd_pixels8_xy2_num, 1);
#endif /* ALTIVEC_USE_REFERENCE_C_CODE */
}
/* next one assumes that ((line_size % 16) == 0) */
void put_pixels16_xy2_altivec(uint8_t * block, const uint8_t * pixels, int line_size, int h)
{
-POWERPC_TBL_DECLARE(altivec_put_pixels16_xy2_num, 1);
+POWERPC_PERF_DECLARE(altivec_put_pixels16_xy2_num, 1);
#ifdef ALTIVEC_USE_REFERENCE_C_CODE
int j;
-POWERPC_TBL_START_COUNT(altivec_put_pixels16_xy2_num, 1);
+POWERPC_PERF_START_COUNT(altivec_put_pixels16_xy2_num, 1);
for (j = 0; j < 4; j++) {
int i;
const uint32_t a = (((const struct unaligned_32 *) (pixels))->l);
@@ -1073,7 +1106,7 @@ POWERPC_TBL_START_COUNT(altivec_put_pixels16_xy2_num, 1);
block += 4 - line_size * h;
}
-POWERPC_TBL_STOP_COUNT(altivec_put_pixels16_xy2_num, 1);
+POWERPC_PERF_STOP_COUNT(altivec_put_pixels16_xy2_num, 1);
#else /* ALTIVEC_USE_REFERENCE_C_CODE */
register int i;
@@ -1086,7 +1119,9 @@ POWERPC_TBL_STOP_COUNT(altivec_put_pixels16_xy2_num, 1);
pixelssum3, pixelssum4, temp4;
register const vector unsigned char vczero = (const vector unsigned char)vec_splat_u8(0);
register const vector unsigned short vctwo = (const vector unsigned short)vec_splat_u16(2);
-
+
+POWERPC_PERF_START_COUNT(altivec_put_pixels16_xy2_num, 1);
+
temp1 = vec_ld(0, pixels);
temp2 = vec_ld(16, pixels);
pixelsv1 = vec_perm(temp1, temp2, vec_lvsl(0, pixels));
@@ -1109,7 +1144,6 @@ POWERPC_TBL_STOP_COUNT(altivec_put_pixels16_xy2_num, 1);
(vector unsigned short)pixelsv2);
pixelssum1 = vec_add(pixelssum1, vctwo);
-POWERPC_TBL_START_COUNT(altivec_put_pixels16_xy2_num, 1);
for (i = 0; i < h ; i++) {
blockv = vec_ld(0, block);
@@ -1150,17 +1184,17 @@ POWERPC_TBL_START_COUNT(altivec_put_pixels16_xy2_num, 1);
pixels += line_size;
}
-POWERPC_TBL_STOP_COUNT(altivec_put_pixels16_xy2_num, 1);
+POWERPC_PERF_STOP_COUNT(altivec_put_pixels16_xy2_num, 1);
#endif /* ALTIVEC_USE_REFERENCE_C_CODE */
}
/* next one assumes that ((line_size % 16) == 0) */
void put_no_rnd_pixels16_xy2_altivec(uint8_t * block, const uint8_t * pixels, int line_size, int h)
{
-POWERPC_TBL_DECLARE(altivec_put_no_rnd_pixels16_xy2_num, 1);
+POWERPC_PERF_DECLARE(altivec_put_no_rnd_pixels16_xy2_num, 1);
#ifdef ALTIVEC_USE_REFERENCE_C_CODE
int j;
-POWERPC_TBL_START_COUNT(altivec_put_no_rnd_pixels16_xy2_num, 1);
+POWERPC_PERF_START_COUNT(altivec_put_no_rnd_pixels16_xy2_num, 1);
for (j = 0; j < 4; j++) {
int i;
const uint32_t a = (((const struct unaligned_32 *) (pixels))->l);
@@ -1193,7 +1227,7 @@ POWERPC_TBL_START_COUNT(altivec_put_no_rnd_pixels16_xy2_num, 1);
block += 4 - line_size * h;
}
-POWERPC_TBL_STOP_COUNT(altivec_put_no_rnd_pixels16_xy2_num, 1);
+POWERPC_PERF_STOP_COUNT(altivec_put_no_rnd_pixels16_xy2_num, 1);
#else /* ALTIVEC_USE_REFERENCE_C_CODE */
register int i;
@@ -1207,7 +1241,9 @@ POWERPC_TBL_STOP_COUNT(altivec_put_no_rnd_pixels16_xy2_num, 1);
register const vector unsigned char vczero = (const vector unsigned char)vec_splat_u8(0);
register const vector unsigned short vcone = (const vector unsigned short)vec_splat_u16(1);
register const vector unsigned short vctwo = (const vector unsigned short)vec_splat_u16(2);
-
+
+POWERPC_PERF_START_COUNT(altivec_put_no_rnd_pixels16_xy2_num, 1);
+
temp1 = vec_ld(0, pixels);
temp2 = vec_ld(16, pixels);
pixelsv1 = vec_perm(temp1, temp2, vec_lvsl(0, pixels));
@@ -1230,7 +1266,6 @@ POWERPC_TBL_STOP_COUNT(altivec_put_no_rnd_pixels16_xy2_num, 1);
(vector unsigned short)pixelsv2);
pixelssum1 = vec_add(pixelssum1, vcone);
-POWERPC_TBL_START_COUNT(altivec_put_no_rnd_pixels16_xy2_num, 1);
for (i = 0; i < h ; i++) {
blockv = vec_ld(0, block);
@@ -1271,7 +1306,7 @@ POWERPC_TBL_START_COUNT(altivec_put_no_rnd_pixels16_xy2_num, 1);
pixels += line_size;
}
-POWERPC_TBL_STOP_COUNT(altivec_put_no_rnd_pixels16_xy2_num, 1);
+POWERPC_PERF_STOP_COUNT(altivec_put_no_rnd_pixels16_xy2_num, 1);
#endif /* ALTIVEC_USE_REFERENCE_C_CODE */
}
diff --git a/src/libffmpeg/libavcodec/ppc/dsputil_ppc.c b/src/libffmpeg/libavcodec/ppc/dsputil_ppc.c
index 374309e37..7af2aa002 100644
--- a/src/libffmpeg/libavcodec/ppc/dsputil_ppc.c
+++ b/src/libffmpeg/libavcodec/ppc/dsputil_ppc.c
@@ -33,7 +33,7 @@ int mm_flags = 0;
int mm_support(void)
{
int result = 0;
-#if HAVE_ALTIVEC
+#ifdef HAVE_ALTIVEC
if (has_altivec()) {
result |= MM_ALTIVEC;
}
@@ -41,8 +41,8 @@ int mm_support(void)
return result;
}
-#ifdef POWERPC_TBL_PERFORMANCE_REPORT
-unsigned long long perfdata[powerpc_perf_total][powerpc_data_total];
+#ifdef POWERPC_PERFORMANCE_REPORT
+unsigned long long perfdata[POWERPC_NUM_PMC_ENABLED][powerpc_perf_total][powerpc_data_total];
/* list below must match enum in dsputil_ppc.h */
static unsigned char* perfname[] = {
"fft_calc_altivec",
@@ -57,46 +57,35 @@ static unsigned char* perfname[] = {
"put_no_rnd_pixels8_xy2_altivec",
"put_pixels16_xy2_altivec",
"put_no_rnd_pixels16_xy2_altivec",
- "clear_blocks_dcbz32_ppc"
+ "clear_blocks_dcbz32_ppc",
+ "clear_blocks_dcbz128_ppc"
};
-#ifdef POWERPC_PERF_USE_PMC
-unsigned long long perfdata_miss[powerpc_perf_total][powerpc_data_total];
-#endif
#include <stdio.h>
#endif
-#ifdef POWERPC_TBL_PERFORMANCE_REPORT
+#ifdef POWERPC_PERFORMANCE_REPORT
void powerpc_display_perf_report(void)
{
- int i;
-#ifndef POWERPC_PERF_USE_PMC
- fprintf(stderr, "PowerPC performance report\n Values are from the Time Base register, and represent 4 bus cycles.\n");
-#else /* POWERPC_PERF_USE_PMC */
+ int i, j;
fprintf(stderr, "PowerPC performance report\n Values are from the PMC registers, and represent whatever the registers are set to record.\n");
-#endif /* POWERPC_PERF_USE_PMC */
for(i = 0 ; i < powerpc_perf_total ; i++)
{
- if (perfdata[i][powerpc_data_num] != (unsigned long long)0)
- fprintf(stderr, " Function \"%s\" (pmc1):\n\tmin: %llu\n\tmax: %llu\n\tavg: %1.2lf (%llu)\n",
- perfname[i],
- perfdata[i][powerpc_data_min],
- perfdata[i][powerpc_data_max],
- (double)perfdata[i][powerpc_data_sum] /
- (double)perfdata[i][powerpc_data_num],
- perfdata[i][powerpc_data_num]);
-#ifdef POWERPC_PERF_USE_PMC
- if (perfdata_miss[i][powerpc_data_num] != (unsigned long long)0)
- fprintf(stderr, " Function \"%s\" (pmc2):\n\tmin: %llu\n\tmax: %llu\n\tavg: %1.2lf (%llu)\n",
- perfname[i],
- perfdata_miss[i][powerpc_data_min],
- perfdata_miss[i][powerpc_data_max],
- (double)perfdata_miss[i][powerpc_data_sum] /
- (double)perfdata_miss[i][powerpc_data_num],
- perfdata_miss[i][powerpc_data_num]);
-#endif
+ for (j = 0; j < POWERPC_NUM_PMC_ENABLED ; j++)
+ {
+ if (perfdata[j][i][powerpc_data_num] != (unsigned long long)0)
+ fprintf(stderr,
+ " Function \"%s\" (pmc%d):\n\tmin: %llu\n\tmax: %llu\n\tavg: %1.2lf (%llu)\n",
+ perfname[i],
+ j+1,
+ perfdata[j][i][powerpc_data_min],
+ perfdata[j][i][powerpc_data_max],
+ (double)perfdata[j][i][powerpc_data_sum] /
+ (double)perfdata[j][i][powerpc_data_num],
+ perfdata[j][i][powerpc_data_num]);
+ }
}
}
-#endif /* POWERPC_TBL_PERFORMANCE_REPORT */
+#endif /* POWERPC_PERFORMANCE_REPORT */
/* ***** WARNING ***** WARNING ***** WARNING ***** */
/*
@@ -110,13 +99,25 @@ void powerpc_display_perf_report(void)
It simply clear to zero a single cache line,
so you need to know the cache line size to use it !
It's absurd, but it's fast...
+
+ update 24/06/2003 : Apple released yesterday the G5,
+ with a PPC970. cache line size : 128 bytes. Oups.
+ The semantic of dcbz was changed, it always clear
+ 32 bytes. so the function below will work, but will
+ be slow. So I fixed check_dcbz_effect to use dcbzl,
+ which is defined to clear a cache line (as dcbz before).
+ So we still can distinguish, and use dcbz (32 bytes)
+ or dcbzl (one cache line) as required.
+
+ see <http://developer.apple.com/technotes/tn/tn2087.html>
+ and <http://developer.apple.com/technotes/tn/tn2086.html>
*/
void clear_blocks_dcbz32_ppc(DCTELEM *blocks)
{
-POWERPC_TBL_DECLARE(powerpc_clear_blocks_dcbz32, 1);
+POWERPC_PERF_DECLARE(powerpc_clear_blocks_dcbz32, 1);
register int misal = ((unsigned long)blocks & 0x00000010);
register int i = 0;
-POWERPC_TBL_START_COUNT(powerpc_clear_blocks_dcbz32, 1);
+POWERPC_PERF_START_COUNT(powerpc_clear_blocks_dcbz32, 1);
#if 1
if (misal) {
((unsigned long*)blocks)[0] = 0L;
@@ -126,7 +127,7 @@ POWERPC_TBL_START_COUNT(powerpc_clear_blocks_dcbz32, 1);
i += 16;
}
for ( ; i < sizeof(DCTELEM)*6*64 ; i += 32) {
- asm volatile("dcbz %0,%1" : : "r" (blocks), "r" (i) : "memory");
+ asm volatile("dcbz %0,%1" : : "b" (blocks), "r" (i) : "memory");
}
if (misal) {
((unsigned long*)blocks)[188] = 0L;
@@ -138,11 +139,48 @@ POWERPC_TBL_START_COUNT(powerpc_clear_blocks_dcbz32, 1);
#else
memset(blocks, 0, sizeof(DCTELEM)*6*64);
#endif
-POWERPC_TBL_STOP_COUNT(powerpc_clear_blocks_dcbz32, 1);
+POWERPC_PERF_STOP_COUNT(powerpc_clear_blocks_dcbz32, 1);
+}
+
+/* same as above, when dcbzl clear a whole 128B cache line
+ i.e. the PPC970 aka G5 */
+#ifndef NO_DCBZL
+void clear_blocks_dcbz128_ppc(DCTELEM *blocks)
+{
+POWERPC_PERF_DECLARE(powerpc_clear_blocks_dcbz128, 1);
+ register int misal = ((unsigned long)blocks & 0x0000007f);
+ register int i = 0;
+POWERPC_PERF_START_COUNT(powerpc_clear_blocks_dcbz128, 1);
+#if 1
+ if (misal) {
+ // we could probably also optimize this case,
+ // but there's not much point as the machines
+ // aren't available yet (2003-06-26)
+ memset(blocks, 0, sizeof(DCTELEM)*6*64);
+ }
+ else
+ for ( ; i < sizeof(DCTELEM)*6*64 ; i += 128) {
+ asm volatile("dcbzl %0,%1" : : "b" (blocks), "r" (i) : "memory");
+ }
+#else
+ memset(blocks, 0, sizeof(DCTELEM)*6*64);
+#endif
+POWERPC_PERF_STOP_COUNT(powerpc_clear_blocks_dcbz128, 1);
+}
+#else
+void clear_blocks_dcbz128_ppc(DCTELEM *blocks)
+{
+ memset(blocks, 0, sizeof(DCTELEM)*6*64);
}
+#endif
+#ifndef NO_DCBZL
/* check dcbz report how many bytes are set to 0 by dcbz */
-long check_dcbz_effect(void)
+/* update 24/06/2003 : replace dcbz by dcbzl to get
+ the intended effect (Apple "fixed" dcbz)
+ unfortunately this cannot be used unless the assembler
+ knows about dcbzl ... */
+long check_dcbzl_effect(void)
{
register char *fakedata = (char*)av_malloc(1024);
register char *fakedata_middle;
@@ -159,7 +197,9 @@ long check_dcbz_effect(void)
memset(fakedata, 0xFF, 1024);
- asm volatile("dcbz %0, %1" : : "r" (fakedata_middle), "r" (zero));
+ /* below the constraint "b" seems to mean "Address base register"
+ in gcc-3.3 / RS/6000 speaks. seems to avoid using r0, so.... */
+ asm volatile("dcbzl %0, %1" : : "b" (fakedata_middle), "r" (zero));
for (i = 0; i < 1024 ; i ++)
{
@@ -171,20 +211,29 @@ long check_dcbz_effect(void)
return count;
}
+#else
+long check_dcbzl_effect(void)
+{
+ return 0;
+}
+#endif
void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx)
{
- // Common optimisations whether Altivec or not
+ // Common optimizations whether Altivec is available or not
- switch (check_dcbz_effect()) {
+ switch (check_dcbzl_effect()) {
case 32:
c->clear_blocks = clear_blocks_dcbz32_ppc;
break;
+ case 128:
+ c->clear_blocks = clear_blocks_dcbz128_ppc;
+ break;
default:
break;
}
-#if HAVE_ALTIVEC
+#ifdef HAVE_ALTIVEC
if (has_altivec()) {
mm_flags |= MM_ALTIVEC;
@@ -207,6 +256,8 @@ void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx)
c->add_bytes= add_bytes_altivec;
#endif /* 0 */
c->put_pixels_tab[0][0] = put_pixels16_altivec;
+ /* the tow functions do the same thing, so use the same code */
+ c->put_no_rnd_pixels_tab[0][0] = put_pixels16_altivec;
c->avg_pixels_tab[0][0] = avg_pixels16_altivec;
// next one disabled as it's untested.
#if 0
@@ -231,24 +282,21 @@ void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx)
#endif /* ALTIVEC_USE_REFERENCE_C_CODE */
}
-#ifdef POWERPC_TBL_PERFORMANCE_REPORT
+#ifdef POWERPC_PERFORMANCE_REPORT
{
- int i;
+ int i, j;
for (i = 0 ; i < powerpc_perf_total ; i++)
{
- perfdata[i][powerpc_data_min] = 0xFFFFFFFFFFFFFFFF;
- perfdata[i][powerpc_data_max] = 0x0000000000000000;
- perfdata[i][powerpc_data_sum] = 0x0000000000000000;
- perfdata[i][powerpc_data_num] = 0x0000000000000000;
-#ifdef POWERPC_PERF_USE_PMC
- perfdata_miss[i][powerpc_data_min] = 0xFFFFFFFFFFFFFFFF;
- perfdata_miss[i][powerpc_data_max] = 0x0000000000000000;
- perfdata_miss[i][powerpc_data_sum] = 0x0000000000000000;
- perfdata_miss[i][powerpc_data_num] = 0x0000000000000000;
-#endif /* POWERPC_PERF_USE_PMC */
- }
+ for (j = 0; j < POWERPC_NUM_PMC_ENABLED ; j++)
+ {
+ perfdata[j][i][powerpc_data_min] = (unsigned long long)0xFFFFFFFFFFFFFFFF;
+ perfdata[j][i][powerpc_data_max] = (unsigned long long)0x0000000000000000;
+ perfdata[j][i][powerpc_data_sum] = (unsigned long long)0x0000000000000000;
+ perfdata[j][i][powerpc_data_num] = (unsigned long long)0x0000000000000000;
+ }
+ }
}
-#endif /* POWERPC_TBL_PERFORMANCE_REPORT */
+#endif /* POWERPC_PERFORMANCE_REPORT */
} else
#endif /* HAVE_ALTIVEC */
{
diff --git a/src/libffmpeg/libavcodec/ppc/dsputil_ppc.h b/src/libffmpeg/libavcodec/ppc/dsputil_ppc.h
index ef1481a99..4cb299dd9 100644
--- a/src/libffmpeg/libavcodec/ppc/dsputil_ppc.h
+++ b/src/libffmpeg/libavcodec/ppc/dsputil_ppc.h
@@ -19,8 +19,21 @@
#ifndef _DSPUTIL_PPC_
#define _DSPUTIL_PPC_
-#ifdef POWERPC_TBL_PERFORMANCE_REPORT
+#ifdef CONFIG_DARWIN
+/* The Apple assembler shipped w/ gcc-3.3 knows about DCBZL, previous assemblers don't
+ We assume here that the Darwin GCC is from Apple.... */
+#if (__GNUC__ * 100 + __GNUC_MINOR__ < 303)
+#define NO_DCBZL
+#endif
+#else /* CONFIG_DARWIN */
+/* I don't think any non-Apple assembler knows about DCBZL */
+#define NO_DCBZL
+#endif /* CONFIG_DARWIN */
+
+#ifdef POWERPC_PERFORMANCE_REPORT
void powerpc_display_perf_report(void);
+/* the 604* have 2, the G3* have 4, the G4s have 6 */
+#define POWERPC_NUM_PMC_ENABLED 4
/* if you add to the enum below, also add to the perfname array
in dsputil_ppc.c */
enum powerpc_perf_index {
@@ -37,6 +50,7 @@ enum powerpc_perf_index {
altivec_put_pixels16_xy2_num,
altivec_put_no_rnd_pixels16_xy2_num,
powerpc_clear_blocks_dcbz32,
+ powerpc_clear_blocks_dcbz128,
powerpc_perf_total
};
enum powerpc_data_index {
@@ -46,78 +60,65 @@ enum powerpc_data_index {
powerpc_data_num,
powerpc_data_total
};
-extern unsigned long long perfdata[powerpc_perf_total][powerpc_data_total];
-#ifdef POWERPC_PERF_USE_PMC
-extern unsigned long long perfdata_miss[powerpc_perf_total][powerpc_data_total];
-#endif
-
-#ifndef POWERPC_PERF_USE_PMC
-#define POWERPC_GET_CYCLES(a) asm volatile("mftb %0" : "=r" (a))
-#define POWERPC_TBL_DECLARE(a, cond) register unsigned long tbl_start, tbl_stop
-#define POWERPC_TBL_START_COUNT(a, cond) do { POWERPC_GET_CYCLES(tbl_start); } while (0)
-#define POWERPC_TBL_STOP_COUNT(a, cond) do { \
- POWERPC_GET_CYCLES(tbl_stop); \
- if (tbl_stop > tbl_start) \
- { \
- unsigned long diff = tbl_stop - tbl_start; \
- if (cond) \
- { \
- if (diff < perfdata[a][powerpc_data_min]) \
- perfdata[a][powerpc_data_min] = diff; \
- if (diff > perfdata[a][powerpc_data_max]) \
- perfdata[a][powerpc_data_max] = diff; \
- perfdata[a][powerpc_data_sum] += diff; \
- perfdata[a][powerpc_data_num] ++; \
- } \
- } \
-} while (0)
+extern unsigned long long perfdata[POWERPC_NUM_PMC_ENABLED][powerpc_perf_total][powerpc_data_total];
-#else /* POWERPC_PERF_USE_PMC */
-#define POWERPC_GET_CYCLES(a) asm volatile("mfspr %0, 937" : "=r" (a))
-#define POWERPC_GET_MISS(a) asm volatile("mfspr %0, 938" : "=r" (a))
-#define POWERPC_TBL_DECLARE(a, cond) register unsigned long cycles_start, cycles_stop, miss_start, miss_stop
-#define POWERPC_TBL_START_COUNT(a, cond) do { POWERPC_GET_MISS(miss_start); POWERPC_GET_CYCLES(cycles_start); } while (0)
-#define POWERPC_TBL_STOP_COUNT(a, cond) do { \
- POWERPC_GET_CYCLES(cycles_stop); \
- POWERPC_GET_MISS(miss_stop); \
- if (cycles_stop >= cycles_start) \
- { \
- unsigned long diff = \
- cycles_stop - cycles_start; \
- if (cond) \
- { \
- if (diff < perfdata[a][powerpc_data_min]) \
- perfdata[a][powerpc_data_min] = diff; \
- if (diff > perfdata[a][powerpc_data_max]) \
- perfdata[a][powerpc_data_max] = diff; \
- perfdata[a][powerpc_data_sum] += diff; \
- perfdata[a][powerpc_data_num] ++; \
- } \
- } \
- if (miss_stop >= miss_start) \
- { \
- unsigned long diff = \
- miss_stop - miss_start; \
- if (cond) \
- { \
- if (diff < perfdata_miss[a][powerpc_data_min]) \
- perfdata_miss[a][powerpc_data_min] = diff; \
- if (diff > perfdata_miss[a][powerpc_data_max]) \
- perfdata_miss[a][powerpc_data_max] = diff; \
- perfdata_miss[a][powerpc_data_sum] += diff; \
- perfdata_miss[a][powerpc_data_num] ++; \
- } \
- } \
+#define POWERPC_GET_PMC1(a) asm volatile("mfspr %0, 937" : "=r" (a))
+#define POWERPC_GET_PMC2(a) asm volatile("mfspr %0, 938" : "=r" (a))
+#if (POWERPC_NUM_PMC_ENABLED > 2)
+#define POWERPC_GET_PMC3(a) asm volatile("mfspr %0, 941" : "=r" (a))
+#define POWERPC_GET_PMC4(a) asm volatile("mfspr %0, 942" : "=r" (a))
+#else
+#define POWERPC_GET_PMC3(a) do {} while (0)
+#define POWERPC_GET_PMC4(a) do {} while (0)
+#endif
+#if (POWERPC_NUM_PMC_ENABLED > 4)
+#define POWERPC_GET_PMC5(a) asm volatile("mfspr %0, 929" : "=r" (a))
+#define POWERPC_GET_PMC6(a) asm volatile("mfspr %0, 930" : "=r" (a))
+#else
+#define POWERPC_GET_PMC5(a) do {} while (0)
+#define POWERPC_GET_PMC6(a) do {} while (0)
+#endif
+#define POWERPC_PERF_DECLARE(a, cond) unsigned long pmc_start[POWERPC_NUM_PMC_ENABLED], pmc_stop[POWERPC_NUM_PMC_ENABLED], pmc_loop_index;
+#define POWERPC_PERF_START_COUNT(a, cond) do { \
+ POWERPC_GET_PMC6(pmc_start[5]); \
+ POWERPC_GET_PMC5(pmc_start[4]); \
+ POWERPC_GET_PMC4(pmc_start[3]); \
+ POWERPC_GET_PMC3(pmc_start[2]); \
+ POWERPC_GET_PMC2(pmc_start[1]); \
+ POWERPC_GET_PMC1(pmc_start[0]); \
+ } while (0)
+#define POWERPC_PERF_STOP_COUNT(a, cond) do { \
+ POWERPC_GET_PMC1(pmc_stop[0]); \
+ POWERPC_GET_PMC2(pmc_stop[1]); \
+ POWERPC_GET_PMC3(pmc_stop[2]); \
+ POWERPC_GET_PMC4(pmc_stop[3]); \
+ POWERPC_GET_PMC5(pmc_stop[4]); \
+ POWERPC_GET_PMC6(pmc_stop[5]); \
+ if (cond) \
+ { \
+ for(pmc_loop_index = 0; \
+ pmc_loop_index < POWERPC_NUM_PMC_ENABLED; \
+ pmc_loop_index++) \
+ { \
+ if (pmc_stop[pmc_loop_index] >= pmc_start[pmc_loop_index]) \
+ { \
+ unsigned long diff = \
+ pmc_stop[pmc_loop_index] - pmc_start[pmc_loop_index]; \
+ if (diff < perfdata[pmc_loop_index][a][powerpc_data_min]) \
+ perfdata[pmc_loop_index][a][powerpc_data_min] = diff; \
+ if (diff > perfdata[pmc_loop_index][a][powerpc_data_max]) \
+ perfdata[pmc_loop_index][a][powerpc_data_max] = diff; \
+ perfdata[pmc_loop_index][a][powerpc_data_sum] += diff; \
+ perfdata[pmc_loop_index][a][powerpc_data_num] ++; \
+ } \
+ } \
+ } \
} while (0)
-
-#endif /* POWERPC_PERF_USE_PMC */
-
-
-#else /* POWERPC_TBL_PERFORMANCE_REPORT */
+#else /* POWERPC_PERFORMANCE_REPORT */
// those are needed to avoid empty statements.
-#define POWERPC_TBL_DECLARE(a, cond) int altivec_placeholder __attribute__ ((unused))
-#define POWERPC_TBL_START_COUNT(a, cond) do {} while (0)
-#define POWERPC_TBL_STOP_COUNT(a, cond) do {} while (0)
-#endif /* POWERPC_TBL_PERFORMANCE_REPORT */
+#define POWERPC_PERF_DECLARE(a, cond) int altivec_placeholder __attribute__ ((unused))
+#define POWERPC_PERF_START_COUNT(a, cond) do {} while (0)
+#define POWERPC_PERF_STOP_COUNT(a, cond) do {} while (0)
+#endif /* POWERPC_PERFORMANCE_REPORT */
#endif /* _DSPUTIL_PPC_ */
diff --git a/src/libffmpeg/libavcodec/ppc/fft_altivec.c b/src/libffmpeg/libavcodec/ppc/fft_altivec.c
index 75c95bb87..e39c9dbb7 100644
--- a/src/libffmpeg/libavcodec/ppc/fft_altivec.c
+++ b/src/libffmpeg/libavcodec/ppc/fft_altivec.c
@@ -62,7 +62,7 @@
*/
void fft_calc_altivec(FFTContext *s, FFTComplex *z)
{
-POWERPC_TBL_DECLARE(altivec_fft_num, s->nbits >= 6);
+POWERPC_PERF_DECLARE(altivec_fft_num, s->nbits >= 6);
#ifdef ALTIVEC_USE_REFERENCE_C_CODE
int ln = s->nbits;
int j, np, np2;
@@ -72,7 +72,7 @@ POWERPC_TBL_DECLARE(altivec_fft_num, s->nbits >= 6);
int l;
FFTSample tmp_re, tmp_im;
-POWERPC_TBL_START_COUNT(altivec_fft_num, s->nbits >= 6);
+POWERPC_PERF_START_COUNT(altivec_fft_num, s->nbits >= 6);
np = 1 << ln;
@@ -137,7 +137,7 @@ POWERPC_TBL_START_COUNT(altivec_fft_num, s->nbits >= 6);
nloops = nloops << 1;
} while (nblocks != 0);
-POWERPC_TBL_STOP_COUNT(altivec_fft_num, s->nbits >= 6);
+POWERPC_PERF_STOP_COUNT(altivec_fft_num, s->nbits >= 6);
#else /* ALTIVEC_USE_REFERENCE_C_CODE */
#ifdef CONFIG_DARWIN
@@ -153,7 +153,7 @@ POWERPC_TBL_STOP_COUNT(altivec_fft_num, s->nbits >= 6);
FFTComplex *cptr, *cptr1;
int k;
-POWERPC_TBL_START_COUNT(altivec_fft_num, s->nbits >= 6);
+POWERPC_PERF_START_COUNT(altivec_fft_num, s->nbits >= 6);
np = 1 << ln;
@@ -241,7 +241,7 @@ POWERPC_TBL_START_COUNT(altivec_fft_num, s->nbits >= 6);
nloops = nloops << 1;
} while (nblocks != 0);
-POWERPC_TBL_STOP_COUNT(altivec_fft_num, s->nbits >= 6);
+POWERPC_PERF_STOP_COUNT(altivec_fft_num, s->nbits >= 6);
#endif /* ALTIVEC_USE_REFERENCE_C_CODE */
}
diff --git a/src/libffmpeg/libavcodec/ppc/gcc_fixes.h b/src/libffmpeg/libavcodec/ppc/gcc_fixes.h
index 855a5b4f7..a8e92cb2f 100644
--- a/src/libffmpeg/libavcodec/ppc/gcc_fixes.h
+++ b/src/libffmpeg/libavcodec/ppc/gcc_fixes.h
@@ -15,7 +15,6 @@
#define AVV(x...) (x)
#else
#define AVV(x...) {x}
-
#if (__GNUC__ * 100 + __GNUC_MINOR__ < 303)
/* This code was provided to me by Bartosch Pixa
@@ -26,7 +25,7 @@
* http://gcc.gnu.org/ml/gcc/2003-04/msg00967.html
*/
-static inline vector signed char my_vmrglb (vector signed char const A,
+static inline vector signed char ff_vmrglb (vector signed char const A,
vector signed char const B)
{
static const vector unsigned char lowbyte = {
@@ -36,7 +35,7 @@ static inline vector signed char my_vmrglb (vector signed char const A,
return vec_perm (A, B, lowbyte);
}
-static inline vector signed short my_vmrglh (vector signed short const A,
+static inline vector signed short ff_vmrglh (vector signed short const A,
vector signed short const B)
{
static const vector unsigned char lowhalf = {
@@ -46,7 +45,7 @@ static inline vector signed short my_vmrglh (vector signed short const A,
return vec_perm (A, B, lowhalf);
}
-static inline vector signed int my_vmrglw (vector signed int const A,
+static inline vector signed int ff_vmrglw (vector signed int const A,
vector signed int const B)
{
static const vector unsigned char lowword = {
@@ -55,27 +54,27 @@ static inline vector signed int my_vmrglw (vector signed int const A,
};
return vec_perm (A, B, lowword);
}
-/*#define my_vmrglb my_vmrglb
-#define my_vmrglh my_vmrglh
-#define my_vmrglw my_vmrglw
+/*#define ff_vmrglb ff_vmrglb
+#define ff_vmrglh ff_vmrglh
+#define ff_vmrglw ff_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))), \
+ ((vector signed char) ff_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))), \
+ ((vector unsigned char) ff_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))), \
+ ((vector signed short) ff_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))), \
+ ((vector unsigned short) ff_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))), \
+ ((vector float) ff_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))), \
+ ((vector signed int) ff_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))), \
+ ((vector unsigned int) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
__altivec_link_error_invalid_argument ())))))))
#endif
diff --git a/src/libffmpeg/libavcodec/ppc/gmc_altivec.c b/src/libffmpeg/libavcodec/ppc/gmc_altivec.c
index 18d52bbc5..671ee110a 100644
--- a/src/libffmpeg/libavcodec/ppc/gmc_altivec.c
+++ b/src/libffmpeg/libavcodec/ppc/gmc_altivec.c
@@ -28,9 +28,10 @@
altivec-enhanced gmc1. ATM this code assume stride is a multiple of 8,
to preserve proper dst alignement.
*/
+#define GMC1_PERF_COND (h==8)
void gmc1_altivec(uint8_t *dst /* align 8 */, uint8_t *src /* align1 */, int stride, int h, int x16, int y16, int rounder)
{
-POWERPC_TBL_DECLARE(altivec_gmc1_num, h == 8);
+POWERPC_PERF_DECLARE(altivec_gmc1_num, GMC1_PERF_COND);
#ifdef ALTIVEC_USE_REFERENCE_C_CODE
const int A=(16-x16)*(16-y16);
const int B=( x16)*(16-y16);
@@ -38,7 +39,7 @@ POWERPC_TBL_DECLARE(altivec_gmc1_num, h == 8);
const int D=( x16)*( y16);
int i;
-POWERPC_TBL_START_COUNT(altivec_gmc1_num, h == 8);
+POWERPC_PERF_START_COUNT(altivec_gmc1_num, GMC1_PERF_COND);
for(i=0; i<h; i++)
{
@@ -54,7 +55,7 @@ POWERPC_TBL_START_COUNT(altivec_gmc1_num, h == 8);
src+= stride;
}
-POWERPC_TBL_STOP_COUNT(altivec_gmc1_num, h == 8);
+POWERPC_PERF_STOP_COUNT(altivec_gmc1_num, GMC1_PERF_COND);
#else /* ALTIVEC_USE_REFERENCE_C_CODE */
const unsigned short __attribute__ ((aligned(16))) rounder_a[8] =
@@ -77,7 +78,7 @@ POWERPC_TBL_STOP_COUNT(altivec_gmc1_num, h == 8);
unsigned long src_really_odd = (unsigned long)src & 0x0000000F;
-POWERPC_TBL_START_COUNT(altivec_gmc1_num, h == 8);
+POWERPC_PERF_START_COUNT(altivec_gmc1_num, GMC1_PERF_COND);
tempA = vec_ld(0, (unsigned short*)ABCD);
Av = vec_splat(tempA, 0);
@@ -165,7 +166,7 @@ POWERPC_TBL_START_COUNT(altivec_gmc1_num, h == 8);
src += stride;
}
-POWERPC_TBL_STOP_COUNT(altivec_gmc1_num, h == 8);
+POWERPC_PERF_STOP_COUNT(altivec_gmc1_num, GMC1_PERF_COND);
#endif /* ALTIVEC_USE_REFERENCE_C_CODE */
}
diff --git a/src/libffmpeg/libavcodec/ppc/idct_altivec.c b/src/libffmpeg/libavcodec/ppc/idct_altivec.c
index f8a8aa678..d821ecd22 100644
--- a/src/libffmpeg/libavcodec/ppc/idct_altivec.c
+++ b/src/libffmpeg/libavcodec/ppc/idct_altivec.c
@@ -165,16 +165,16 @@ static const vector_s16_t constants[5] = {
void idct_put_altivec(uint8_t* dest, int stride, vector_s16_t* block)
{
-POWERPC_TBL_DECLARE(altivec_idct_put_num, 1);
+POWERPC_PERF_DECLARE(altivec_idct_put_num, 1);
#ifdef ALTIVEC_USE_REFERENCE_C_CODE
-POWERPC_TBL_START_COUNT(altivec_idct_put_num, 1);
+POWERPC_PERF_START_COUNT(altivec_idct_put_num, 1);
void simple_idct_put(uint8_t *dest, int line_size, int16_t *block);
simple_idct_put(dest, stride, (int16_t*)block);
-POWERPC_TBL_STOP_COUNT(altivec_idct_put_num, 1);
+POWERPC_PERF_STOP_COUNT(altivec_idct_put_num, 1);
#else /* ALTIVEC_USE_REFERENCE_C_CODE */
vector_u8_t tmp;
-POWERPC_TBL_START_COUNT(altivec_idct_put_num, 1);
+POWERPC_PERF_START_COUNT(altivec_idct_put_num, 1);
IDCT
@@ -192,18 +192,18 @@ POWERPC_TBL_START_COUNT(altivec_idct_put_num, 1);
COPY (dest, vx6) dest += stride;
COPY (dest, vx7)
-POWERPC_TBL_STOP_COUNT(altivec_idct_put_num, 1);
+POWERPC_PERF_STOP_COUNT(altivec_idct_put_num, 1);
#endif /* ALTIVEC_USE_REFERENCE_C_CODE */
}
void idct_add_altivec(uint8_t* dest, int stride, vector_s16_t* block)
{
-POWERPC_TBL_DECLARE(altivec_idct_add_num, 1);
+POWERPC_PERF_DECLARE(altivec_idct_add_num, 1);
#ifdef ALTIVEC_USE_REFERENCE_C_CODE
-POWERPC_TBL_START_COUNT(altivec_idct_add_num, 1);
+POWERPC_PERF_START_COUNT(altivec_idct_add_num, 1);
void simple_idct_add(uint8_t *dest, int line_size, int16_t *block);
simple_idct_add(dest, stride, (int16_t*)block);
-POWERPC_TBL_STOP_COUNT(altivec_idct_add_num, 1);
+POWERPC_PERF_STOP_COUNT(altivec_idct_add_num, 1);
#else /* ALTIVEC_USE_REFERENCE_C_CODE */
vector_u8_t tmp;
vector_s16_t tmp2, tmp3;
@@ -211,7 +211,7 @@ POWERPC_TBL_STOP_COUNT(altivec_idct_add_num, 1);
vector_u8_t perm1;
vector_u8_t p0, p1, p;
-POWERPC_TBL_START_COUNT(altivec_idct_add_num, 1);
+POWERPC_PERF_START_COUNT(altivec_idct_add_num, 1);
IDCT
@@ -239,7 +239,7 @@ POWERPC_TBL_START_COUNT(altivec_idct_add_num, 1);
ADD (dest, vx6, perm0) dest += stride;
ADD (dest, vx7, perm1)
-POWERPC_TBL_STOP_COUNT(altivec_idct_add_num, 1);
+POWERPC_PERF_STOP_COUNT(altivec_idct_add_num, 1);
#endif /* ALTIVEC_USE_REFERENCE_C_CODE */
}
diff --git a/src/libffmpeg/libavcodec/ppc/mpegvideo_altivec.c b/src/libffmpeg/libavcodec/ppc/mpegvideo_altivec.c
index bbf9c4433..ae3170d91 100644
--- a/src/libffmpeg/libavcodec/ppc/mpegvideo_altivec.c
+++ b/src/libffmpeg/libavcodec/ppc/mpegvideo_altivec.c
@@ -522,13 +522,13 @@ int dct_quantize_altivec(MpegEncContext* s,
void dct_unquantize_h263_altivec(MpegEncContext *s,
DCTELEM *block, int n, int qscale)
{
-POWERPC_TBL_DECLARE(altivec_dct_unquantize_h263_num, 1);
+POWERPC_PERF_DECLARE(altivec_dct_unquantize_h263_num, 1);
int i, level, qmul, qadd;
int nCoeffs;
assert(s->block_last_index[n]>=0);
-POWERPC_TBL_START_COUNT(altivec_dct_unquantize_h263_num, 1);
+POWERPC_PERF_START_COUNT(altivec_dct_unquantize_h263_num, 1);
qadd = (qscale - 1) | 1;
qmul = qscale << 1;
@@ -641,5 +641,5 @@ POWERPC_TBL_START_COUNT(altivec_dct_unquantize_h263_num, 1);
}
#endif /* ALTIVEC_USE_REFERENCE_C_CODE */
-POWERPC_TBL_STOP_COUNT(altivec_dct_unquantize_h263_num, nCoeffs == 63);
+POWERPC_PERF_STOP_COUNT(altivec_dct_unquantize_h263_num, nCoeffs == 63);
}
diff --git a/src/libffmpeg/libavcodec/ppc/mpegvideo_ppc.c b/src/libffmpeg/libavcodec/ppc/mpegvideo_ppc.c
index c290dde16..18e86dce9 100644
--- a/src/libffmpeg/libavcodec/ppc/mpegvideo_ppc.c
+++ b/src/libffmpeg/libavcodec/ppc/mpegvideo_ppc.c
@@ -36,7 +36,7 @@ extern void idct_add_altivec(uint8_t *dest, int line_size, int16_t *block);
void MPV_common_init_ppc(MpegEncContext *s)
{
-#if HAVE_ALTIVEC
+#ifdef HAVE_ALTIVEC
if (has_altivec())
{
if ((s->avctx->idct_algo == FF_IDCT_AUTO) ||
diff --git a/src/libffmpeg/libavcodec/ra144.c b/src/libffmpeg/libavcodec/ra144.c
index 443db6e87..2d882f744 100644
--- a/src/libffmpeg/libavcodec/ra144.c
+++ b/src/libffmpeg/libavcodec/ra144.c
@@ -18,6 +18,7 @@
*/
#include "avcodec.h"
+#include "ra144.h"
#define DATABLOCK1 20 /* size of 14.4 input block in bytes */
#define DATACHUNK1 1440 /* size of 14.4 input chunk in bytes */
@@ -70,2410 +71,6 @@ typedef struct {
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;
@@ -2588,7 +185,6 @@ static int irms(short *data, int factor)
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;
@@ -2711,7 +307,6 @@ static unsigned int rms(int *data, int f)
{
int *c;
int x;
- int d;
unsigned int res;
int b;
diff --git a/src/libffmpeg/libavcodec/ra144.h b/src/libffmpeg/libavcodec/ra144.h
new file mode 100644
index 000000000..f95a8bab3
--- /dev/null
+++ b/src/libffmpeg/libavcodec/ra144.h
@@ -0,0 +1,2426 @@
+/*
+ * 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
+ */
+
+#ifndef RA144TABLES_H
+#define RA144TABLES_H
+
+/* 14.4 data tables */
+static 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};
+
+static 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};
+
+static 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};
+
+static 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};
+
+static 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};
+
+static 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};
+
+static 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};
+
+static const short *decodetable[11]={
+decodetable1,decodetable2,decodetable3,decodetable4,decodetable5,
+decodetable6,decodetable7,decodetable8,decodetable9,decodetable10,
+decodetable11};
+
+#endif /* RA144TABLES_H */
diff --git a/src/libffmpeg/libavcodec/ra288.c b/src/libffmpeg/libavcodec/ra288.c
index 7b6df3bf5..b59074822 100644
--- a/src/libffmpeg/libavcodec/ra288.c
+++ b/src/libffmpeg/libavcodec/ra288.c
@@ -18,6 +18,7 @@
*/
#include "avcodec.h"
+#include "ra288.h"
typedef struct {
float history[8];
@@ -32,187 +33,6 @@ typedef struct {
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;
@@ -348,7 +168,7 @@ static void co(int n, int i, int j, float *in, float *out, float *st1, float *st
{
int a,b,c;
unsigned int x;
- float *fp,*fp2;
+ float *fp;
float buffer1[37];
float buffer2[37];
float work[111];
diff --git a/src/libffmpeg/libavcodec/ra288.h b/src/libffmpeg/libavcodec/ra288.h
new file mode 100644
index 000000000..7cc0d8724
--- /dev/null
+++ b/src/libffmpeg/libavcodec/ra288.h
@@ -0,0 +1,203 @@
+/*
+ * 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
+ */
+
+#ifndef RA288TABLES_H
+#define RA288TABLES_H
+
+static const float amptable[8]={ 0.515625, 0.90234375, 1.57910156, 2.76342773,
+ -0.515625,-0.90234375,-1.57910156,-2.76342773 };
+
+static 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
+};
+
+static 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
+};
+
+static 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
+};
+
+static 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
+};
+
+static const float table2a[10]={
+ 0.90625, 0.821289063, 0.74432373, 0.674499512, 0.61126709,
+ 0.553955078, 0.50201416, 0.454956055, 0.41229248, 0.373657227
+};
+
+#endif /* RA288TABLES_H */
diff --git a/src/libffmpeg/libavcodec/ratecontrol.c b/src/libffmpeg/libavcodec/ratecontrol.c
index 80f65d924..a786ac215 100644
--- a/src/libffmpeg/libavcodec/ratecontrol.c
+++ b/src/libffmpeg/libavcodec/ratecontrol.c
@@ -38,9 +38,9 @@ static int init_pass2(MpegEncContext *s);
static double get_qscale(MpegEncContext *s, RateControlEntry *rce, double rate_factor, int frame_num);
void ff_write_pass1_stats(MpegEncContext *s){
- sprintf(s->avctx->stats_out, "in:%d out:%d type:%d q:%f itex:%d ptex:%d mv:%d misc:%d fcode:%d bcode:%d mc-var:%d var:%d icount:%d;\n",
+ sprintf(s->avctx->stats_out, "in:%d out:%d type:%d q:%d itex:%d ptex:%d mv:%d misc:%d fcode:%d bcode:%d mc-var:%d var:%d icount:%d;\n",
s->picture_number, s->input_picture_number - s->max_b_frames, s->pict_type,
- s->frame_qscale, s->i_tex_bits, s->p_tex_bits, s->mv_bits, s->misc_bits,
+ s->current_picture.quality, s->i_tex_bits, s->p_tex_bits, s->mv_bits, s->misc_bits,
s->f_code, s->b_code, s->current_picture.mc_mb_var_sum, s->current_picture.mb_var_sum, s->i_count);
}
@@ -51,7 +51,7 @@ int ff_rate_control_init(MpegEncContext *s)
emms_c();
for(i=0; i<5; i++){
- rcc->pred[i].coeff= 7.0;
+ rcc->pred[i].coeff= FF_QP2LAMBDA * 7.0;
rcc->pred[i].count= 1.0;
rcc->pred[i].decay= 0.4;
@@ -60,7 +60,7 @@ int ff_rate_control_init(MpegEncContext *s)
rcc->mv_bits_sum[i]=
rcc->qscale_sum [i]=
rcc->frame_count[i]= 1; // 1 is better cuz of 1/0 and such
- rcc->last_qscale_for[i]=5;
+ rcc->last_qscale_for[i]=FF_QP2LAMBDA * 5;
}
rcc->buffer_index= s->avctx->rc_buffer_size/2;
@@ -81,7 +81,7 @@ int ff_rate_control_init(MpegEncContext *s)
for(i=0; i<rcc->num_entries; i++){
RateControlEntry *rce= &rcc->entry[i];
rce->pict_type= rce->new_pict_type=P_TYPE;
- rce->qscale= rce->new_qscale=2;
+ rce->qscale= rce->new_qscale=FF_QP2LAMBDA * 2;
rce->misc_bits= s->mb_num + 10;
rce->mb_var_sum= s->mb_num*100;
}
@@ -140,7 +140,7 @@ int ff_rate_control_init(MpegEncContext *s)
rce.new_pict_type= rce.pict_type;
rce.mc_mb_var_sum= bits*s->mb_num/100000;
rce.mb_var_sum = s->mb_num;
- rce.qscale = 2;
+ rce.qscale = FF_QP2LAMBDA * 2;
rce.f_code = 2;
rce.b_code = 1;
rce.misc_bits= 1;
@@ -339,9 +339,10 @@ static double get_diff_limited_q(MpegEncContext *s, RateControlEntry *rce, doubl
/* last qscale / qdiff stuff */
if(rcc->last_non_b_pict_type==pict_type || pict_type!=I_TYPE){
double last_q= rcc->last_qscale_for[pict_type];
+ const int maxdiff= FF_QP2LAMBDA * a->max_qdiff;
- if (q > last_q + a->max_qdiff) q= last_q + a->max_qdiff;
- else if(q < last_q - a->max_qdiff) q= last_q - a->max_qdiff;
+ if (q > last_q + maxdiff) q= last_q + maxdiff;
+ else if(q < last_q - maxdiff) q= last_q - maxdiff;
}
rcc->last_qscale_for[pict_type]= q; //Note we cant do that after blurring
@@ -356,8 +357,10 @@ static double get_diff_limited_q(MpegEncContext *s, RateControlEntry *rce, doubl
* gets the qmin & qmax for pict_type
*/
static void get_qminmax(int *qmin_ret, int *qmax_ret, MpegEncContext *s, int pict_type){
- int qmin= s->avctx->qmin;
- int qmax= s->avctx->qmax;
+ int qmin= s->avctx->lmin;
+ int qmax= s->avctx->lmax;
+
+ assert(qmin <= qmax);
if(pict_type==B_TYPE){
qmin= (int)(qmin*ABS(s->avctx->b_quant_factor)+s->avctx->b_quant_offset + 0.5);
@@ -367,13 +370,10 @@ static void get_qminmax(int *qmin_ret, int *qmax_ret, MpegEncContext *s, int pic
qmax= (int)(qmax*ABS(s->avctx->i_quant_factor)+s->avctx->i_quant_offset + 0.5);
}
- if(qmin<1) qmin=1;
- if(qmin==1 && s->avctx->qmin>1) qmin=2; //avoid qmin=1 unless the user wants qmin=1
-
- if(qmin<3 && s->max_qcoeff<=128 && pict_type==I_TYPE) qmin=3; //reduce cliping problems
+ qmin= clip(qmin, 1, FF_LAMBDA_MAX);
+ qmax= clip(qmax, 1, FF_LAMBDA_MAX);
- if(qmax>31) qmax=31;
- if(qmax<=qmin) qmax= qmin= (qmax+qmin+1)>>1;
+ if(qmax<qmin) qmax= qmin;
*qmin_ret= qmin;
*qmax_ret= qmax;
@@ -476,21 +476,23 @@ static void adaptive_quantization(MpegEncContext *s, double q){
float cplx_sum= 0.0;
float cplx_tab[s->mb_num];
float bits_tab[s->mb_num];
- const int qmin= s->avctx->mb_qmin;
- const int qmax= s->avctx->mb_qmax;
+ const int qmin= s->avctx->lmin;
+ const int qmax= s->avctx->lmax;
Picture * const pic= &s->current_picture;
- int last_qscale=0;
for(i=0; i<s->mb_num; i++){
const int mb_xy= s->mb_index2xy[i];
- float temp_cplx= sqrt(pic->mc_mb_var[mb_xy]);
+ float temp_cplx= sqrt(pic->mc_mb_var[mb_xy]); //FIXME merge in pow()
float spat_cplx= sqrt(pic->mb_var[mb_xy]);
const int lumi= pic->mb_mean[mb_xy];
float bits, cplx, factor;
-
+#if 0
if(spat_cplx < q/3) spat_cplx= q/3; //FIXME finetune
if(temp_cplx < q/3) temp_cplx= q/3; //FIXME finetune
-
+#endif
+ if(spat_cplx < 4) spat_cplx= 4; //FIXME finetune
+ if(temp_cplx < 4) temp_cplx= 4; //FIXME finetune
+
if((s->mb_type[mb_xy]&MB_TYPE_INTRA)){//FIXME hq mode
cplx= spat_cplx;
factor= 1.0 + p_masking;
@@ -540,19 +542,16 @@ static void adaptive_quantization(MpegEncContext *s, double q){
newq*= bits_sum/cplx_sum;
}
- if(i && ABS(last_qscale - newq)<0.75)
- intq= last_qscale;
- else
- intq= (int)(newq + 0.5);
+ intq= (int)(newq + 0.5);
if (intq > qmax) intq= qmax;
else if(intq < qmin) intq= qmin;
//if(i%s->mb_width==0) printf("\n");
//printf("%2d%3d ", intq, ff_sqrt(s->mc_mb_var[i]));
- last_qscale=
- pic->qscale_table[mb_xy]= intq;
+ s->lambda_table[mb_xy]= intq;
}
}
+//FIXME rd or at least approx for dquant
float ff_rate_estimate_qscale(MpegEncContext *s)
{
@@ -599,6 +598,7 @@ float ff_rate_estimate_qscale(MpegEncContext *s)
var= pict_type == I_TYPE ? pic->mb_var_sum : pic->mc_mb_var_sum;
+ short_term_q = 0; /* avoid warning */
if(s->flags&CODEC_FLAG_PASS2){
if(pict_type!=I_TYPE)
assert(pict_type == rce->new_pict_type);
@@ -610,7 +610,7 @@ float ff_rate_estimate_qscale(MpegEncContext *s)
rce->new_pict_type= pict_type;
rce->mc_mb_var_sum= pic->mc_mb_var_sum;
rce->mb_var_sum = pic-> mb_var_sum;
- rce->qscale = 2;
+ rce->qscale = FF_QP2LAMBDA * 2;
rce->f_code = s->f_code;
rce->b_code = s->b_code;
rce->misc_bits= 1;
diff --git a/src/libffmpeg/libavcodec/rational.c b/src/libffmpeg/libavcodec/rational.c
new file mode 100644
index 000000000..92db8bbe3
--- /dev/null
+++ b/src/libffmpeg/libavcodec/rational.c
@@ -0,0 +1,61 @@
+/*
+ * Rational numbers
+ * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * 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 rational.c
+ * Rational numbers
+ * @author Michael Niedermayer <michaelni@gmx.at>
+ */
+
+//#include <math.h>
+#include <limits.h>
+
+#include "common.h"
+#include "avcodec.h"
+#include "rational.h"
+
+AVRational av_mul_q(AVRational b, AVRational c){
+ av_reduce(&b.num, &b.den, b.num * (int64_t)c.num, b.den * (int64_t)c.den, INT_MAX);
+ return b;
+}
+
+AVRational av_div_q(AVRational b, AVRational c){
+ av_reduce(&b.num, &b.den, b.num * (int64_t)c.den, b.den * (int64_t)c.num, INT_MAX);
+ return b;
+}
+
+AVRational av_add_q(AVRational b, AVRational c){
+ av_reduce(&b.num, &b.den, b.num * (int64_t)c.den + c.num * (int64_t)b.den, b.den * (int64_t)c.den, INT_MAX);
+ return b;
+}
+
+AVRational av_sub_q(AVRational b, AVRational c){
+ av_reduce(&b.num, &b.den, b.num * (int64_t)c.den - c.num * (int64_t)b.den, b.den * (int64_t)c.den, INT_MAX);
+ return b;
+}
+
+AVRational av_d2q(double d, int max){
+ AVRational a;
+ int exponent= FFMAX( (int)(log(ABS(d) + 1e-20)/log(2)), 0);
+ int64_t den= 1LL << (61 - exponent);
+ av_reduce(&a.num, &a.den, (int64_t)(d * den + 0.5), den, max);
+
+ return a;
+}
diff --git a/src/libffmpeg/libavcodec/rational.h b/src/libffmpeg/libavcodec/rational.h
new file mode 100644
index 000000000..d5fc77f1a
--- /dev/null
+++ b/src/libffmpeg/libavcodec/rational.h
@@ -0,0 +1,53 @@
+/*
+ * Rational numbers
+ * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * 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 rational.h
+ * Rational numbers.
+ * @author Michael Niedermayer <michaelni@gmx.at>
+ */
+
+#ifndef RATIONAL_H
+#define RATIONAL_H
+
+typedef struct AVRational{
+ int num;
+ int den;
+} AVRational;
+
+static inline int av_cmp_q(AVRational a, AVRational b){
+ const int64_t tmp= a.num * (int64_t)b.den - b.num * (int64_t)a.den;
+
+ if (tmp < 0) return -1;
+ else if(tmp == 0) return 0;
+ else return 1;
+}
+
+static inline double av_q2d(AVRational a){
+ return a.num / (double) a.den;
+}
+
+AVRational av_mul_q(AVRational b, AVRational c);
+AVRational av_div_q(AVRational b, AVRational c);
+AVRational av_add_q(AVRational b, AVRational c);
+AVRational av_sub_q(AVRational b, AVRational c);
+AVRational av_d2q(double d, int max);
+
+#endif // RATIONAL_H
diff --git a/src/libffmpeg/libavcodec/roqvideo.c b/src/libffmpeg/libavcodec/roqvideo.c
new file mode 100644
index 000000000..f1cb52805
--- /dev/null
+++ b/src/libffmpeg/libavcodec/roqvideo.c
@@ -0,0 +1,501 @@
+/*
+ * 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
+ *
+ */
+
+/**
+ * @file roqvideo.c
+ * Id RoQ Video Decoder by Dr. Tim Ferguson
+ * For more information about the Id RoQ format, visit:
+ * http://www.csse.monash.edu.au/~timf/
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "common.h"
+#include "avcodec.h"
+#include "dsputil.h"
+
+typedef struct {
+ unsigned char y0, y1, y2, y3, u, v;
+} roq_cell;
+
+typedef struct {
+ int idx[4];
+} roq_qcell;
+
+static int uiclip[1024], *uiclp; /* clipping table */
+#define avg2(a,b) uiclp[(((int)(a)+(int)(b)+1)>>1)]
+#define avg4(a,b,c,d) uiclp[(((int)(a)+(int)(b)+(int)(c)+(int)(d)+2)>>2)]
+
+typedef struct RoqContext {
+
+ AVCodecContext *avctx;
+ DSPContext dsp;
+ AVFrame last_frame;
+ AVFrame current_frame;
+ int first_frame;
+ int y_stride;
+ int c_stride;
+
+ roq_cell cells[256];
+ roq_qcell qcells[256];
+
+ unsigned char *buf;
+ int size;
+
+} RoqContext;
+
+#define RoQ_INFO 0x1001
+#define RoQ_QUAD_CODEBOOK 0x1002
+#define RoQ_QUAD_VQ 0x1011
+#define RoQ_SOUND_MONO 0x1020
+#define RoQ_SOUND_STEREO 0x1021
+
+#define RoQ_ID_MOT 0x00
+#define RoQ_ID_FCC 0x01
+#define RoQ_ID_SLD 0x02
+#define RoQ_ID_CCC 0x03
+
+#define get_byte(in_buffer) *(in_buffer++)
+#define get_word(in_buffer) ((unsigned short)(in_buffer += 2, \
+ (in_buffer[-1] << 8 | in_buffer[-2])))
+#define get_long(in_buffer) ((unsigned long)(in_buffer += 4, \
+ (in_buffer[-1] << 24 | in_buffer[-2] << 16 | in_buffer[-3] << 8 | in_buffer[-4])))
+
+
+static void apply_vector_2x2(RoqContext *ri, int x, int y, roq_cell *cell)
+{
+ unsigned char *yptr;
+
+ yptr = ri->current_frame.data[0] + (y * ri->y_stride) + x;
+ *yptr++ = cell->y0;
+ *yptr++ = cell->y1;
+ yptr += (ri->y_stride - 2);
+ *yptr++ = cell->y2;
+ *yptr++ = cell->y3;
+ ri->current_frame.data[1][(y/2) * (ri->c_stride) + x/2] = cell->u;
+ ri->current_frame.data[2][(y/2) * (ri->c_stride) + x/2] = cell->v;
+}
+
+static void apply_vector_4x4(RoqContext *ri, int x, int y, roq_cell *cell)
+{
+ unsigned long row_inc, c_row_inc;
+ register unsigned char y0, y1, u, v;
+ unsigned char *yptr, *uptr, *vptr;
+
+ yptr = ri->current_frame.data[0] + (y * ri->y_stride) + x;
+ uptr = ri->current_frame.data[1] + (y/2) * (ri->c_stride) + x/2;
+ vptr = ri->current_frame.data[2] + (y/2) * (ri->c_stride) + x/2;
+
+ row_inc = ri->y_stride - 4;
+ c_row_inc = (ri->c_stride) - 2;
+ *yptr++ = y0 = cell->y0; *uptr++ = u = cell->u; *vptr++ = v = cell->v;
+ *yptr++ = y0;
+ *yptr++ = y1 = cell->y1; *uptr++ = u; *vptr++ = v;
+ *yptr++ = y1;
+
+ yptr += row_inc;
+
+ *yptr++ = y0;
+ *yptr++ = y0;
+ *yptr++ = y1;
+ *yptr++ = y1;
+
+ yptr += row_inc; uptr += c_row_inc; vptr += c_row_inc;
+
+ *yptr++ = y0 = cell->y2; *uptr++ = u; *vptr++ = v;
+ *yptr++ = y0;
+ *yptr++ = y1 = cell->y3; *uptr++ = u; *vptr++ = v;
+ *yptr++ = y1;
+
+ yptr += row_inc;
+
+ *yptr++ = y0;
+ *yptr++ = y0;
+ *yptr++ = y1;
+ *yptr++ = y1;
+}
+
+static void apply_motion_4x4(RoqContext *ri, int x, int y, unsigned char mv,
+ signed char mean_x, signed char mean_y)
+{
+ int i, hw, mx, my;
+ unsigned char *pa, *pb;
+
+ mx = x + 8 - (mv >> 4) - mean_x;
+ my = y + 8 - (mv & 0xf) - mean_y;
+
+ pa = ri->current_frame.data[0] + (y * ri->y_stride) + x;
+ pb = ri->last_frame.data[0] + (my * ri->y_stride) + mx;
+ for(i = 0; i < 4; i++) {
+ pa[0] = pb[0];
+ pa[1] = pb[1];
+ pa[2] = pb[2];
+ pa[3] = pb[3];
+ pa += ri->y_stride;
+ pb += ri->y_stride;
+ }
+
+#if 0
+ pa = ri->current_frame.data[1] + (y/2) * (ri->c_stride) + x/2;
+ pb = ri->last_frame.data[1] + (my/2) * (ri->c_stride) + (mx + 1)/2;
+ for(i = 0; i < 2; i++) {
+ pa[0] = pb[0];
+ pa[1] = pb[1];
+ pa += ri->c_stride;
+ pb += ri->c_stride;
+ }
+
+ pa = ri->current_frame.data[2] + (y/2) * (ri->c_stride) + x/2;
+ pb = ri->last_frame.data[2] + (my/2) * (ri->c_stride) + (mx + 1)/2;
+ for(i = 0; i < 2; i++) {
+ pa[0] = pb[0];
+ pa[1] = pb[1];
+ pa += ri->c_stride;
+ pb += ri->c_stride;
+ }
+#else
+ hw = ri->y_stride/2;
+ pa = ri->current_frame.data[1] + (y * ri->y_stride)/4 + x/2;
+ pb = ri->last_frame.data[1] + (my/2) * (ri->y_stride/2) + (mx + 1)/2;
+
+ for(i = 0; i < 2; i++) {
+ switch(((my & 0x01) << 1) | (mx & 0x01)) {
+
+ case 0:
+ pa[0] = pb[0];
+ pa[1] = pb[1];
+ pa[hw] = pb[hw];
+ pa[hw+1] = pb[hw+1];
+ break;
+
+ case 1:
+ pa[0] = avg2(pb[0], pb[1]);
+ pa[1] = avg2(pb[1], pb[2]);
+ pa[hw] = avg2(pb[hw], pb[hw+1]);
+ pa[hw+1] = avg2(pb[hw+1], pb[hw+2]);
+ break;
+
+ case 2:
+ pa[0] = avg2(pb[0], pb[hw]);
+ pa[1] = avg2(pb[1], pb[hw+1]);
+ pa[hw] = avg2(pb[hw], pb[hw*2]);
+ pa[hw+1] = avg2(pb[hw+1], pb[(hw*2)+1]);
+ break;
+
+ case 3:
+ pa[0] = avg4(pb[0], pb[1], pb[hw], pb[hw+1]);
+ pa[1] = avg4(pb[1], pb[2], pb[hw+1], pb[hw+2]);
+ pa[hw] = avg4(pb[hw], pb[hw+1], pb[hw*2], pb[(hw*2)+1]);
+ pa[hw+1] = avg4(pb[hw+1], pb[hw+2], pb[(hw*2)+1], pb[(hw*2)+1]);
+ break;
+ }
+
+ pa = ri->current_frame.data[2] + (y * ri->y_stride)/4 + x/2;
+ pb = ri->last_frame.data[2] + (my/2) * (ri->y_stride/2) + (mx + 1)/2;
+ }
+#endif
+}
+
+static void apply_motion_8x8(RoqContext *ri, int x, int y,
+ unsigned char mv, signed char mean_x, signed char mean_y)
+{
+ int mx, my, i, j, hw;
+ unsigned char *pa, *pb;
+
+ mx = x + 8 - (mv >> 4) - mean_x;
+ my = y + 8 - (mv & 0xf) - mean_y;
+
+ pa = ri->current_frame.data[0] + (y * ri->y_stride) + x;
+ pb = ri->last_frame.data[0] + (my * ri->y_stride) + mx;
+ for(i = 0; i < 8; i++) {
+ pa[0] = pb[0];
+ pa[1] = pb[1];
+ pa[2] = pb[2];
+ pa[3] = pb[3];
+ pa[4] = pb[4];
+ pa[5] = pb[5];
+ pa[6] = pb[6];
+ pa[7] = pb[7];
+ pa += ri->y_stride;
+ pb += ri->y_stride;
+ }
+
+#if 0
+ pa = ri->current_frame.data[1] + (y/2) * (ri->c_stride) + x/2;
+ pb = ri->last_frame.data[1] + (my/2) * (ri->c_stride) + (mx + 1)/2;
+ for(i = 0; i < 4; i++) {
+ pa[0] = pb[0];
+ pa[1] = pb[1];
+ pa[2] = pb[2];
+ pa[3] = pb[3];
+ pa += ri->c_stride;
+ pb += ri->c_stride;
+ }
+
+ pa = ri->current_frame.data[2] + (y/2) * (ri->c_stride) + x/2;
+ pb = ri->last_frame.data[2] + (my/2) * (ri->c_stride) + (mx + 1)/2;
+ for(i = 0; i < 4; i++) {
+ pa[0] = pb[0];
+ pa[1] = pb[1];
+ pa[2] = pb[2];
+ pa[3] = pb[3];
+ pa += ri->c_stride;
+ pb += ri->c_stride;
+ }
+#else
+ hw = ri->c_stride;
+ pa = ri->current_frame.data[1] + (y * ri->y_stride)/4 + x/2;
+ pb = ri->last_frame.data[1] + (my/2) * (ri->y_stride/2) + (mx + 1)/2;
+ for(j = 0; j < 2; j++) {
+ for(i = 0; i < 4; i++) {
+ switch(((my & 0x01) << 1) | (mx & 0x01)) {
+
+ case 0:
+ pa[0] = pb[0];
+ pa[1] = pb[1];
+ pa[2] = pb[2];
+ pa[3] = pb[3];
+ break;
+
+ case 1:
+ pa[0] = avg2(pb[0], pb[1]);
+ pa[1] = avg2(pb[1], pb[2]);
+ pa[2] = avg2(pb[2], pb[3]);
+ pa[3] = avg2(pb[3], pb[4]);
+ break;
+
+ case 2:
+ pa[0] = avg2(pb[0], pb[hw]);
+ pa[1] = avg2(pb[1], pb[hw+1]);
+ pa[2] = avg2(pb[2], pb[hw+2]);
+ pa[3] = avg2(pb[3], pb[hw+3]);
+ break;
+
+ case 3:
+ pa[0] = avg4(pb[0], pb[1], pb[hw], pb[hw+1]);
+ pa[1] = avg4(pb[1], pb[2], pb[hw+1], pb[hw+2]);
+ pa[2] = avg4(pb[2], pb[3], pb[hw+2], pb[hw+3]);
+ pa[3] = avg4(pb[3], pb[4], pb[hw+3], pb[hw+4]);
+ break;
+ }
+ pa += ri->c_stride;
+ pb += ri->c_stride;
+ }
+
+ pa = ri->current_frame.data[2] + (y * ri->y_stride)/4 + x/2;
+ pb = ri->last_frame.data[2] + (my/2) * (ri->y_stride/2) + (mx + 1)/2;
+ }
+#endif
+}
+
+static void roqvideo_decode_frame(RoqContext *ri)
+{
+ unsigned int chunk_id = 0, chunk_arg = 0;
+ unsigned long chunk_size = 0;
+ int i, j, k, nv1, nv2, vqflg = 0, vqflg_pos = -1;
+ int vqid, bpos, xpos, ypos, xp, yp, x, y;
+ int frame_stats[2][4] = {{0},{0}};
+ roq_qcell *qcell;
+ unsigned char *buf = ri->buf;
+ unsigned char *buf_end = ri->buf + ri->size;
+
+ while (buf < buf_end) {
+ chunk_id = get_word(buf);
+ chunk_size = get_long(buf);
+ chunk_arg = get_word(buf);
+
+ if(chunk_id == RoQ_QUAD_VQ)
+ break;
+ if(chunk_id == RoQ_QUAD_CODEBOOK) {
+ if((nv1 = chunk_arg >> 8) == 0)
+ nv1 = 256;
+ if((nv2 = chunk_arg & 0xff) == 0 && nv1 * 6 < chunk_size)
+ nv2 = 256;
+ for(i = 0; i < nv1; i++) {
+ ri->cells[i].y0 = get_byte(buf);
+ ri->cells[i].y1 = get_byte(buf);
+ ri->cells[i].y2 = get_byte(buf);
+ ri->cells[i].y3 = get_byte(buf);
+ ri->cells[i].u = get_byte(buf);
+ ri->cells[i].v = get_byte(buf);
+ }
+ for(i = 0; i < nv2; i++)
+ for(j = 0; j < 4; j++)
+ ri->qcells[i].idx[j] = get_byte(buf);
+ }
+ }
+
+ bpos = xpos = ypos = 0;
+ while(bpos < chunk_size) {
+ for (yp = ypos; yp < ypos + 16; yp += 8)
+ for (xp = xpos; xp < xpos + 16; xp += 8) {
+ if (vqflg_pos < 0) {
+ vqflg = buf[bpos++]; vqflg |= (buf[bpos++] << 8);
+ vqflg_pos = 7;
+ }
+ vqid = (vqflg >> (vqflg_pos * 2)) & 0x3;
+ frame_stats[0][vqid]++;
+ vqflg_pos--;
+
+ switch(vqid) {
+ case RoQ_ID_MOT:
+ apply_motion_8x8(ri, xp, yp, 0, 8, 8);
+ break;
+ case RoQ_ID_FCC:
+ apply_motion_8x8(ri, xp, yp, buf[bpos++], chunk_arg >> 8,
+ chunk_arg & 0xff);
+ break;
+ case RoQ_ID_SLD:
+ qcell = ri->qcells + buf[bpos++];
+ apply_vector_4x4(ri, xp, yp, ri->cells + qcell->idx[0]);
+ apply_vector_4x4(ri, xp+4, yp, ri->cells + qcell->idx[1]);
+ apply_vector_4x4(ri, xp, yp+4, ri->cells + qcell->idx[2]);
+ apply_vector_4x4(ri, xp+4, yp+4, ri->cells + qcell->idx[3]);
+ break;
+ case RoQ_ID_CCC:
+ for (k = 0; k < 4; k++) {
+ x = xp; y = yp;
+ if(k & 0x01) x += 4;
+ if(k & 0x02) y += 4;
+
+ if (vqflg_pos < 0) {
+ vqflg = buf[bpos++];
+ vqflg |= (buf[bpos++] << 8);
+ vqflg_pos = 7;
+ }
+ vqid = (vqflg >> (vqflg_pos * 2)) & 0x3;
+ frame_stats[1][vqid]++;
+ vqflg_pos--;
+ switch(vqid) {
+ case RoQ_ID_MOT:
+ apply_motion_4x4(ri, x, y, 0, 8, 8);
+ break;
+ case RoQ_ID_FCC:
+ apply_motion_4x4(ri, x, y, buf[bpos++],
+ chunk_arg >> 8, chunk_arg & 0xff);
+ break;
+ case RoQ_ID_SLD:
+ qcell = ri->qcells + buf[bpos++];
+ apply_vector_2x2(ri, x, y, ri->cells + qcell->idx[0]);
+ apply_vector_2x2(ri, x+2, y, ri->cells + qcell->idx[1]);
+ apply_vector_2x2(ri, x, y+2, ri->cells + qcell->idx[2]);
+ apply_vector_2x2(ri, x+2, y+2, ri->cells + qcell->idx[3]);
+ break;
+ case RoQ_ID_CCC:
+ apply_vector_2x2(ri, x, y, ri->cells + buf[bpos]);
+ apply_vector_2x2(ri, x+2, y, ri->cells + buf[bpos+1]);
+ apply_vector_2x2(ri, x, y+2, ri->cells + buf[bpos+2]);
+ apply_vector_2x2(ri, x+2, y+2, ri->cells + buf[bpos+3]);
+ bpos += 4;
+ break;
+ }
+ }
+ break;
+ default:
+ printf("Unknown vq code: %d\n", vqid);
+ }
+ }
+
+ xpos += 16;
+ if (xpos >= ri->avctx->width) {
+ xpos -= ri->avctx->width;
+ ypos += 16;
+ }
+ if(ypos >= ri->avctx->height)
+ break;
+ }
+}
+
+
+static int roq_decode_init(AVCodecContext *avctx)
+{
+ RoqContext *s = avctx->priv_data;
+ int i;
+
+ s->avctx = avctx;
+ s->first_frame = 1;
+ avctx->pix_fmt = PIX_FMT_YUV420P;
+ avctx->has_b_frames = 0;
+ dsputil_init(&s->dsp, avctx);
+
+ uiclp = uiclip+512;
+ for(i = -512; i < 512; i++)
+ uiclp[i] = (i < 0 ? 0 : (i > 255 ? 255 : i));
+
+ return 0;
+}
+
+static int roq_decode_frame(AVCodecContext *avctx,
+ void *data, int *data_size,
+ uint8_t *buf, int buf_size)
+{
+ RoqContext *s = avctx->priv_data;
+
+ *data_size = 0;
+
+ if (avctx->get_buffer(avctx, &s->current_frame)) {
+ printf (" RoQ: get_buffer() failed\n");
+ return -1;
+ }
+ s->y_stride = s->current_frame.linesize[0];
+ s->c_stride = s->current_frame.linesize[1];
+
+ s->buf = buf;
+ s->size = buf_size;
+ roqvideo_decode_frame(s);
+
+ /* release the last frame if it is allocated */
+ if (s->first_frame)
+ s->first_frame = 0;
+ else
+ avctx->release_buffer(avctx, &s->last_frame);
+
+ /* shuffle frames */
+ s->last_frame = s->current_frame;
+
+ *data_size = sizeof(AVFrame);
+ *(AVFrame*)data = s->current_frame;
+
+ return buf_size;
+}
+
+static int roq_decode_end(AVCodecContext *avctx)
+{
+ RoqContext *s = avctx->priv_data;
+
+ /* release the last frame */
+ avctx->release_buffer(avctx, &s->last_frame);
+
+ return 0;
+}
+
+AVCodec roq_decoder = {
+ "roqvideo",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_ROQ,
+ sizeof(RoqContext),
+ roq_decode_init,
+ NULL,
+ roq_decode_end,
+ roq_decode_frame,
+ CODEC_CAP_DR1,
+};
diff --git a/src/libffmpeg/libavcodec/rpza.c b/src/libffmpeg/libavcodec/rpza.c
new file mode 100644
index 000000000..675d7f34c
--- /dev/null
+++ b/src/libffmpeg/libavcodec/rpza.c
@@ -0,0 +1,311 @@
+/*
+ * Quicktime Video (RPZA) Video Decoder
+ * 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
+ *
+ */
+
+/**
+ * @file rpza.c
+ * QT RPZA Video Decoder by Roberto Togni <rtogni@bresciaonline.it>
+ * For more information about the RPZA format, visit:
+ * http://www.pcisys.net/~melanson/codecs/
+ *
+ * The RPZA decoder outputs RGB555 colorspace data.
+ *
+ * Note that this decoder reads big endian RGB555 pixel values from the
+ * bytestream, arranges them in the host's endian order, and outputs
+ * them to the final rendered map in the same host endian order. This is
+ * intended behavior as the ffmpeg documentation states that RGB555 pixels
+ * shall be stored in native CPU endianness.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "common.h"
+#include "avcodec.h"
+#include "dsputil.h"
+
+typedef struct RpzaContext {
+
+ AVCodecContext *avctx;
+ DSPContext dsp;
+ AVFrame frame;
+ AVFrame prev_frame;
+
+ unsigned char *buf;
+ int size;
+
+} RpzaContext;
+
+#define BE_16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1])
+#define BE_32(x) ((((uint8_t*)(x))[0] << 24) | \
+ (((uint8_t*)(x))[1] << 16) | \
+ (((uint8_t*)(x))[2] << 8) | \
+ ((uint8_t*)(x))[3])
+
+#define ADVANCE_BLOCK() \
+{ \
+ pixel_ptr += 4; \
+ if (pixel_ptr >= width) \
+ { \
+ pixel_ptr = 0; \
+ row_ptr += stride * 4; \
+ } \
+ total_blocks--; \
+ if (total_blocks < 0) \
+ { \
+ printf("warning: block counter just went negative (this should not happen)\n"); \
+ return; \
+ } \
+}
+
+static void rpza_decode_stream(RpzaContext *s)
+{
+ int width = s->avctx->width;
+ int stride = s->frame.linesize[0] / 2;
+ int row_inc = stride - 4;
+ int stream_ptr = 0;
+ int chunk_size;
+ unsigned char opcode;
+ int n_blocks;
+ unsigned short colorA = 0, colorB;
+ unsigned short color4[4];
+ unsigned char index, idx;
+ unsigned short ta, tb;
+ unsigned short *pixels = (unsigned short *)s->frame.data[0];
+ unsigned short *prev_pixels = (unsigned short *)s->prev_frame.data[0];
+
+ int row_ptr = 0;
+ int pixel_ptr = 0;
+ int block_ptr;
+ int pixel_x, pixel_y;
+ int total_blocks;
+
+ /* First byte is always 0xe1. Warn if it's different */
+ if (s->buf[stream_ptr] != 0xe1)
+ printf("First chunk byte is 0x%02x instead of 0x1e\n",
+ s->buf[stream_ptr]);
+
+ /* Get chunk size, ingnoring first byte */
+ chunk_size = BE_32(&s->buf[stream_ptr]) & 0x00FFFFFF;
+ stream_ptr += 4;
+
+ /* If length mismatch use size from MOV file and try to decode anyway */
+ if (chunk_size != s->size)
+ printf("MOV chunk size != encoded chunk size; using MOV chunk size\n");
+
+ chunk_size = s->size;
+
+ /* Number of 4x4 blocks in frame. */
+ total_blocks = (s->avctx->width * s->avctx->height) / (4 * 4);
+
+ /* Process chunk data */
+ while (stream_ptr < chunk_size) {
+ opcode = s->buf[stream_ptr++]; /* Get opcode */
+
+ n_blocks = (opcode & 0x1f) + 1; /* Extract block counter from opcode */
+
+ /* If opcode MSbit is 0, we need more data to decide what to do */
+ if ((opcode & 0x80) == 0) {
+ colorA = (opcode << 8) | (s->buf[stream_ptr++]);
+ opcode = 0;
+ if ((s->buf[stream_ptr] & 0x80) != 0) {
+ /* Must behave as opcode 110xxxxx, using colorA computed
+ * above. Use fake opcode 0x20 to enter switch block at
+ * the right place */
+ opcode = 0x20;
+ n_blocks = 1;
+ }
+ }
+
+ switch (opcode & 0xe0) {
+
+ /* Skip blocks */
+ case 0x80:
+ while (n_blocks--) {
+ block_ptr = row_ptr + pixel_ptr;
+ for (pixel_y = 0; pixel_y < 4; pixel_y++) {
+ for (pixel_x = 0; pixel_x < 4; pixel_x++){
+ pixels[block_ptr] = prev_pixels[block_ptr];
+ block_ptr++;
+ }
+ block_ptr += row_inc;
+ }
+ ADVANCE_BLOCK();
+ }
+ break;
+
+ /* Fill blocks with one color */
+ case 0xa0:
+ colorA = BE_16 (&s->buf[stream_ptr]);
+ stream_ptr += 2;
+ while (n_blocks--) {
+ block_ptr = row_ptr + pixel_ptr;
+ for (pixel_y = 0; pixel_y < 4; pixel_y++) {
+ for (pixel_x = 0; pixel_x < 4; pixel_x++){
+ pixels[block_ptr] = colorA;
+ block_ptr++;
+ }
+ block_ptr += row_inc;
+ }
+ ADVANCE_BLOCK();
+ }
+ break;
+
+ /* Fill blocks with 4 colors */
+ case 0xc0:
+ colorA = BE_16 (&s->buf[stream_ptr]);
+ stream_ptr += 2;
+ case 0x20:
+ colorB = BE_16 (&s->buf[stream_ptr]);
+ stream_ptr += 2;
+
+ /* sort out the colors */
+ color4[0] = colorB;
+ color4[1] = 0;
+ color4[2] = 0;
+ color4[3] = colorA;
+
+ /* red components */
+ ta = (colorA >> 10) & 0x1F;
+ tb = (colorB >> 10) & 0x1F;
+ color4[1] |= ((11 * ta + 21 * tb) >> 5) << 10;
+ color4[2] |= ((21 * ta + 11 * tb) >> 5) << 10;
+
+ /* green components */
+ ta = (colorA >> 5) & 0x1F;
+ tb = (colorB >> 5) & 0x1F;
+ color4[1] |= ((11 * ta + 21 * tb) >> 5) << 5;
+ color4[2] |= ((21 * ta + 11 * tb) >> 5) << 5;
+
+ /* blue components */
+ ta = colorA & 0x1F;
+ tb = colorB & 0x1F;
+ color4[1] |= ((11 * ta + 21 * tb) >> 5);
+ color4[2] |= ((21 * ta + 11 * tb) >> 5);
+
+ while (n_blocks--) {
+ block_ptr = row_ptr + pixel_ptr;
+ for (pixel_y = 0; pixel_y < 4; pixel_y++) {
+ index = s->buf[stream_ptr++];
+ for (pixel_x = 0; pixel_x < 4; pixel_x++){
+ idx = (index >> (2 * (3 - pixel_x))) & 0x03;
+ pixels[block_ptr] = color4[idx];
+ block_ptr++;
+ }
+ block_ptr += row_inc;
+ }
+ ADVANCE_BLOCK();
+ }
+ break;
+
+ /* Fill block with 16 colors */
+ case 0x00:
+ block_ptr = row_ptr + pixel_ptr;
+ for (pixel_y = 0; pixel_y < 4; pixel_y++) {
+ for (pixel_x = 0; pixel_x < 4; pixel_x++){
+ /* We already have color of upper left pixel */
+ if ((pixel_y != 0) || (pixel_x !=0)) {
+ colorA = BE_16 (&s->buf[stream_ptr]);
+ stream_ptr += 2;
+ }
+ pixels[block_ptr] = colorA;
+ block_ptr++;
+ }
+ block_ptr += row_inc;
+ }
+ ADVANCE_BLOCK();
+ break;
+
+ /* Unknown opcode */
+ default:
+ printf("Unknown opcode %d in rpza chunk."
+ " Skip remaining %d bytes of chunk data.\n", opcode,
+ chunk_size - stream_ptr);
+ return;
+ } /* Opcode switch */
+ }
+}
+
+static int rpza_decode_init(AVCodecContext *avctx)
+{
+ RpzaContext *s = (RpzaContext *)avctx->priv_data;
+
+ s->avctx = avctx;
+ avctx->pix_fmt = PIX_FMT_RGB555;
+ avctx->has_b_frames = 0;
+ dsputil_init(&s->dsp, avctx);
+
+ s->frame.data[0] = s->prev_frame.data[0] = NULL;
+
+ return 0;
+}
+
+static int rpza_decode_frame(AVCodecContext *avctx,
+ void *data, int *data_size,
+ uint8_t *buf, int buf_size)
+{
+ RpzaContext *s = (RpzaContext *)avctx->priv_data;
+
+ s->buf = buf;
+ s->size = buf_size;
+
+ s->frame.reference = 1;
+ if (avctx->get_buffer(avctx, &s->frame)) {
+ printf (" RPZA Video: get_buffer() failed\n");
+ return -1;
+ }
+
+ rpza_decode_stream(s);
+
+ if (s->prev_frame.data[0])
+ avctx->release_buffer(avctx, &s->prev_frame);
+
+ /* shuffle frames */
+ s->prev_frame = s->frame;
+
+ *data_size = sizeof(AVFrame);
+ *(AVFrame*)data = s->frame;
+
+ /* always report that the buffer was completely consumed */
+ return buf_size;
+}
+
+static int rpza_decode_end(AVCodecContext *avctx)
+{
+ RpzaContext *s = (RpzaContext *)avctx->priv_data;
+
+ if (s->prev_frame.data[0])
+ avctx->release_buffer(avctx, &s->prev_frame);
+
+ return 0;
+}
+
+AVCodec rpza_decoder = {
+ "rpza",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_RPZA,
+ sizeof(RpzaContext),
+ rpza_decode_init,
+ NULL,
+ rpza_decode_end,
+ rpza_decode_frame,
+ CODEC_CAP_DR1,
+};
diff --git a/src/libffmpeg/libavcodec/rv10.c b/src/libffmpeg/libavcodec/rv10.c
index 4b351ea1e..c19c36ec5 100644
--- a/src/libffmpeg/libavcodec/rv10.c
+++ b/src/libffmpeg/libavcodec/rv10.c
@@ -466,6 +466,7 @@ static int rv10_decode_packet(AVCodecContext *avctx,
fprintf(stderr, "ERROR at MB %d %d\n", s->mb_x, s->mb_y);
return -1;
}
+ ff_h263_update_motion_val(s);
MPV_decode_mb(s, s->block);
if (++s->mb_x == s->mb_width) {
s->mb_x = 0;
diff --git a/src/libffmpeg/libavcodec/sp5x.h b/src/libffmpeg/libavcodec/sp5x.h
new file mode 100644
index 000000000..469d1b46d
--- /dev/null
+++ b/src/libffmpeg/libavcodec/sp5x.h
@@ -0,0 +1,330 @@
+/*
+ * Sunplus JPEG tables
+ * 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
+ */
+
+#ifndef SP5X_H
+#define SP5X_H
+
+static uint8_t sp5x_data_sof[] =
+{
+ 0xFF, 0xC0, /* SOF */
+ 0x00, 0x11, /* len */
+ 0x08, /* bits */
+ 0x00, 0xf0, /* height (default: 240) */
+ 0x01, 0x40, /* width (default: 240) */
+ 0x03, /* nb components */
+ 0x01, 0x22, 0x00, /* 21 vs 22 ? */
+ 0x02, 0x11, 0x01,
+ 0x03, 0x11, 0x01
+};
+
+static uint8_t sp5x_data_sos[] =
+{
+ 0xFF, 0xDA, /* SOS */
+ 0x00, 0x0C, /* len */
+ 0x03, /* nb components */
+ 0x01, 0x00,
+ 0x02, 0x11,
+ 0x03, 0x11,
+ 0x00, /* Ss */
+ 0x3F, /* Se */
+ 0x00 /* Ah/Al */
+};
+
+static uint8_t sp5x_data_dqt[] =
+{
+ 0xFF, 0xDB, /* DQT */
+ 0x00, 0x84, /* len */
+ 0x00,
+ 0x05, 0x03, 0x04, 0x04, 0x04, 0x03, 0x05, 0x04,
+ 0x04, 0x04, 0x06, 0x05, 0x05, 0x06, 0x08, 0x0D,
+ 0x08, 0x08, 0x07, 0x07, 0x08, 0x10, 0x0C, 0x0C,
+ 0x0A, 0x0D, 0x14, 0x11, 0x15, 0x14, 0x13, 0x11,
+ 0x13, 0x13, 0x16, 0x18, 0x1F, 0x1A, 0x16, 0x17,
+ 0x1E, 0x17, 0x13, 0x13, 0x1B, 0x25, 0x1C, 0x1E,
+ 0x20, 0x21, 0x23, 0x23, 0x23, 0x15, 0x1A, 0x27,
+ 0x29, 0x26, 0x22, 0x29, 0x1F, 0x22, 0x23, 0x22,
+ 0x01,
+ 0x05, 0x06, 0x06, 0x08, 0x07, 0x08, 0x10, 0x08,
+ 0x08, 0x10, 0x22, 0x16, 0x13, 0x16, 0x22, 0x22,
+ 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
+ 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
+ 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
+ 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
+ 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
+ 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22
+};
+
+static uint8_t sp5x_data_dht[] = {
+ 0xFF, 0xC4, /* DHT */
+ 0x01, 0xA2, /* len */
+ 0x00, 0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
+ 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x01, 0x00, 0x03,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
+ 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
+ 0x0A, 0x0B, 0x10, 0x00, 0x02, 0x01, 0x03, 0x03,
+ 0x02, 0x04, 0x03, 0x05, 0x05, 0x04, 0x04, 0x00,
+ 0x00, 0x01, 0x7D, 0x01, 0x02, 0x03, 0x00, 0x04,
+ 0x11, 0x05, 0x12, 0x21, 0x31, 0x41, 0x06, 0x13,
+ 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, 0x81,
+ 0x91, 0xA1, 0x08, 0x23, 0x42, 0xB1, 0xC1, 0x15,
+ 0x52, 0xD1, 0xF0, 0x24, 0x33, 0x62, 0x72, 0x82,
+ 0x09, 0x0A, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x25,
+ 0x26, 0x27, 0x28, 0x29, 0x2A, 0x34, 0x35, 0x36,
+ 0x37, 0x38, 0x39, 0x3A, 0x43, 0x44, 0x45, 0x46,
+ 0x47, 0x48, 0x49, 0x4A, 0x53, 0x54, 0x55, 0x56,
+ 0x57, 0x58, 0x59, 0x5A, 0x63, 0x64, 0x65, 0x66,
+ 0x67, 0x68, 0x69, 0x6A, 0x73, 0x74, 0x75, 0x76,
+ 0x77, 0x78, 0x79, 0x7A, 0x83, 0x84, 0x85, 0x86,
+ 0x87, 0x88, 0x89, 0x8A, 0x92, 0x93, 0x94, 0x95,
+ 0x96, 0x97, 0x98, 0x99, 0x9A, 0xA2, 0xA3, 0xA4,
+ 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xB2, 0xB3,
+ 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xC2,
+ 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA,
+ 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9,
+ 0xDA, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
+ 0xE8, 0xE9, 0xEA, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5,
+ 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0x11, 0x00, 0x02,
+ 0x01, 0x02, 0x04, 0x04, 0x03, 0x04, 0x07, 0x05,
+ 0x04, 0x04, 0x00, 0x01, 0x02, 0x77, 0x00, 0x01,
+ 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06,
+ 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, 0x13, 0x22,
+ 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, 0xA1, 0xB1,
+ 0xC1, 0x09, 0x23, 0x33, 0x52, 0xF0, 0x15, 0x62,
+ 0x72, 0xD1, 0x0A, 0x16, 0x24, 0x34, 0xE1, 0x25,
+ 0xF1, 0x17, 0x18, 0x19, 0x1A, 0x26, 0x27, 0x28,
+ 0x29, 0x2A, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A,
+ 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A,
+ 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A,
+ 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A,
+ 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A,
+ 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
+ 0x8A, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
+ 0x99, 0x9A, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7,
+ 0xA8, 0xA9, 0xAA, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6,
+ 0xB7, 0xB8, 0xB9, 0xBA, 0xC2, 0xC3, 0xC4, 0xC5,
+ 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xD2, 0xD3, 0xD4,
+ 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xE2, 0xE3,
+ 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xF2,
+ 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA
+};
+
+
+static uint8_t sp5x_quant_table[20][64]=
+{
+ /* index 0, Q50 */
+ { 16, 11, 12, 14, 12, 10, 16, 14, 13, 14, 18, 17, 16, 19, 24, 40,
+ 26, 24, 22, 22, 24, 49, 35, 37, 29, 40, 58, 51, 61, 60, 57, 51,
+ 56, 55, 64, 72, 92, 78, 64, 68, 87, 69, 55, 56, 80,109, 81, 87,
+ 95, 98,103,104,103, 62, 77,113,121,112,100,120, 92,101,103, 99 },
+ { 17, 18, 18, 24, 21, 24, 47, 26, 26, 47, 99, 66, 56, 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, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99 },
+
+ /* index 1, Q70 */
+ { 10, 7, 7, 8, 7, 6, 10, 8, 8, 8, 11, 10, 10, 11, 14, 24,
+ 16, 14, 13, 13, 14, 29, 21, 22, 17, 24, 35, 31, 37, 36, 34, 31,
+ 34, 33, 38, 43, 55, 47, 38, 41, 52, 41, 33, 34, 48, 65, 49, 52,
+ 57, 59, 62, 62, 62, 37, 46, 68, 73, 67, 60, 72, 55, 61, 62, 59 },
+ { 10, 11, 11, 14, 13, 14, 28, 16, 16, 28, 59, 40, 34, 40, 59, 59,
+ 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
+ 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
+ 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59 },
+
+ /* index 2, Q80 */
+ { 6, 4, 5, 6, 5, 4, 6, 6, 5, 6, 7, 7, 6, 8, 10, 16,
+ 10, 10, 9, 9, 10, 20, 14, 15, 12, 16, 23, 20, 24, 24, 23, 20,
+ 22, 22, 26, 29, 37, 31, 26, 27, 35, 28, 22, 22, 32, 44, 32, 35,
+ 38, 39, 41, 42, 41, 25, 31, 45, 48, 45, 40, 48, 37, 40, 41, 40 },
+ { 7, 7, 7, 10, 8, 10, 19, 10, 10, 19, 40, 26, 22, 26, 40, 40,
+ 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
+ 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
+ 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40 },
+
+ /* index 3, Q85 */
+ { 5, 3, 4, 4, 4, 3, 5, 4, 4, 4, 5, 5, 5, 6, 7, 12,
+ 8, 7, 7, 7, 7, 15, 11, 11, 9, 12, 17, 15, 18, 18, 17, 15,
+ 17, 17, 19, 22, 28, 23, 19, 20, 26, 21, 17, 17, 24, 33, 24, 26,
+ 29, 29, 31, 31, 31, 19, 23, 34, 36, 34, 30, 36, 28, 30, 31, 30 },
+ { 5, 5, 5, 7, 6, 7, 14, 8, 8, 14, 30, 20, 17, 20, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30 },
+
+ /* index 4, Q90 */
+ { 3, 2, 2, 3, 2, 2, 3, 3, 3, 3, 4, 3, 3, 4, 5, 8,
+ 5, 5, 4, 4, 5, 10, 7, 7, 6, 8, 12, 10, 12, 12, 11, 10,
+ 11, 11, 13, 14, 18, 16, 13, 14, 17, 14, 11, 11, 16, 22, 16, 17,
+ 19, 20, 21, 21, 21, 12, 15, 23, 24, 22, 20, 24, 18, 20, 21, 20 },
+ { 3, 4, 4, 5, 4, 5, 9, 5, 5, 9, 20, 13, 11, 13, 20, 20,
+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20 },
+
+ /* index 5, Q60 */
+ { 13, 9, 10, 11, 10, 8, 13, 11, 10, 11, 14, 14, 13, 15, 19, 32,
+ 21, 19, 18, 18, 19, 39, 28, 30, 23, 32, 46, 41, 49, 48, 46, 41,
+ 45, 44, 51, 58, 74, 62, 51, 54, 70, 55, 44, 45, 64, 87, 65, 70,
+ 76, 78, 82, 83, 82, 50, 62, 90, 97, 90, 80, 96, 74, 81, 82, 79 },
+ { 14, 14, 14, 19, 17, 19, 38, 21, 21, 38, 79, 53, 45, 53, 79, 79,
+ 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
+ 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
+ 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79 },
+
+ /* index 6, Q25 */
+ { 32, 22, 24, 28, 24, 20, 32, 28, 26, 28, 36, 34, 32, 38, 48, 80,
+ 52, 48, 44, 44, 48, 98, 70, 74, 58, 80,116,102,122,120,114,102,
+ 112,110,128,144,184,156,128,136,174,138,110,112,160,218,162,174,
+ 190,196,206,208,206,124,154,226,242,224,200,240,184,202,206,198 },
+ { 34, 36, 36, 48, 42, 48, 94, 52, 52, 94,198,132,112,132,198,198,
+ 198,198,198,198,198,198,198,198,198,198,198,198,198,198,198,198,
+ 198,198,198,198,198,198,198,198,198,198,198,198,198,198,198,198,
+ 198,198,198,198,198,198,198,198,198,198,198,198,198,198,198,198 },
+
+ /* index 7, Q95 */
+ { 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 2, 2, 2, 2, 4,
+ 3, 2, 2, 2, 2, 5, 4, 4, 3, 4, 6, 5, 6, 6, 6, 5,
+ 6, 6, 6, 7, 9, 8, 6, 7, 9, 7, 6, 6, 8, 11, 8, 9,
+ 10, 10, 10, 10, 10, 6, 8, 11, 12, 11, 10, 12, 9, 10, 10, 10 },
+ { 2, 2, 2, 2, 2, 2, 5, 3, 3, 5, 10, 7, 6, 7, 10, 10,
+ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
+ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
+ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 },
+
+ /* index 8, Q93 */
+ { 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 3, 2, 2, 3, 3, 6,
+ 4, 3, 3, 3, 3, 7, 5, 5, 4, 6, 8, 7, 9, 8, 8, 7,
+ 8, 8, 9, 10, 13, 11, 9, 10, 12, 10, 8, 8, 11, 15, 11, 12,
+ 13, 14, 14, 15, 14, 9, 11, 16, 17, 16, 14, 17, 13, 14, 14, 14 },
+ { 2, 3, 3, 3, 3, 3, 7, 4, 4, 7, 14, 9, 8, 9, 14, 14,
+ 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+ 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+ 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14 },
+
+ /* index 9, Q40 */
+ { 20, 14, 15, 18, 15, 13, 20, 18, 16, 18, 23, 21, 20, 24, 30, 50,
+ 33, 30, 28, 28, 30, 61, 44, 46, 36, 50, 73, 64, 76, 75, 71, 64,
+ 70, 69, 80, 90,115, 98, 80, 85,109, 86, 69, 70,100,136,101,109,
+ 119,123,129,130,129, 78, 96,141,151,140,125,150,115,126,129,124 },
+ { 21, 23, 23, 30, 26, 30, 59, 33, 33, 59,124, 83, 70, 83,124,124,
+ 124,124,124,124,124,124,124,124,124,124,124,124,124,124,124,124,
+ 124,124,124,124,124,124,124,124,124,124,124,124,124,124,124,124,
+ 124,124,124,124,124,124,124,124,124,124,124,124,124,124,124,124 }
+};
+
+#if 0
+/* 4NF-M, not ZigZag */
+static uint8_t sp5x_quant_table_orig[18][64] =
+{
+ /* index 0, Q50 */
+ { 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, 56, 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 },
+ { 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 },
+
+ /* index 1, Q70 */
+ { 10, 7, 6, 10, 14, 24, 31, 37, 7, 7, 8, 11, 16, 35, 36, 33,
+ 8, 8, 10, 14, 24, 34, 41, 34, 8, 10, 13, 17, 31, 52, 48, 37,
+ 11, 13, 22, 34, 41, 65, 62, 46, 14, 21, 33, 38, 49, 62, 68, 55,
+ 29, 38, 47, 52, 62, 73, 72, 61, 43, 55, 57, 59, 67, 60, 62, 59 },
+ { 10, 11, 14, 28, 59, 59, 59, 59, 11, 13, 16, 40, 59, 59, 59, 59,
+ 14, 16, 34, 59, 59, 59, 59, 59, 28, 40, 59, 59, 59, 59, 59, 59,
+ 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
+ 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59 },
+
+ /* index 2, Q80 */
+ { 6, 4, 4, 6, 10, 16, 20, 24, 5, 5, 6, 8, 10, 23, 24, 22,
+ 6, 5, 6, 10, 16, 23, 28, 22, 6, 7, 9, 12, 20, 35, 32, 25,
+ 7, 9, 15, 22, 27, 44, 41, 31, 10, 14, 22, 26, 32, 42, 45, 37,
+ 20, 26, 31, 35, 41, 48, 48, 40, 29, 37, 38, 39, 45, 40, 41, 40 },
+ { 7, 7, 10, 19, 40, 40, 40, 40, 7, 8, 10, 26, 40, 40, 40, 40,
+ 10, 10, 22, 40, 40, 40, 40, 40, 19, 26, 40, 40, 40, 40, 40, 40,
+ 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
+ 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40 },
+
+ /* index 3, Q85 */
+ { 5, 3, 3, 5, 7, 12, 15, 18, 4, 4, 4, 6, 8, 17, 18, 17,
+ 4, 4, 5, 7, 12, 17, 21, 17, 4, 5, 7, 9, 15, 26, 24, 19,
+ 5, 7, 11, 17, 20, 33, 31, 23, 7, 11, 17, 19, 24, 31, 34, 28,
+ 15, 19, 23, 26, 31, 36, 36, 30, 22, 28, 29, 29, 34, 30, 31, 30 },
+ { 5, 5, 7, 14, 30, 30, 30, 30, 5, 6, 8, 20, 30, 30, 30, 30,
+ 7, 8, 17, 30, 30, 30, 30, 30, 14, 20, 30, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30 },
+
+ /* index 4, Q90 */
+ { 3, 2, 2, 3, 5, 8, 10, 12, 2, 2, 3, 4, 5, 12, 12, 11,
+ 3, 3, 3, 5, 8, 11, 14, 11, 3, 3, 4, 6, 10, 17, 16, 12,
+ 4, 4, 7, 11, 14, 22, 21, 15, 5, 7, 11, 13, 16, 21, 23, 18,
+ 10, 13, 16, 17, 21, 24, 24, 20, 14, 18, 19, 20, 22, 20, 21, 20 },
+ { 3, 4, 5, 9, 20, 20, 20, 20, 4, 4, 5, 13, 20, 20, 20, 20,
+ 5, 5, 11, 20, 20, 20, 20, 20, 9, 13, 20, 20, 20, 20, 20, 20,
+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20 },
+
+ /* index 5, Q60 */
+ { 13, 9, 8, 13, 19, 32, 41, 49, 10, 10, 11, 15, 21, 46, 48, 44,
+ 11, 10, 13, 19, 32, 46, 55, 45, 11, 14, 18, 23, 41, 70, 64, 50,
+ 14, 18, 30, 45, 54, 87, 82, 62, 19, 28, 44, 51, 65, 83, 90, 74,
+ 39, 51, 62, 70, 82, 97, 96, 81, 58, 74, 76, 78, 90, 80, 82, 79 },
+ { 14, 14, 19, 38, 79, 79, 79, 79, 14, 17, 21, 53, 79, 79, 79, 79,
+ 19, 21, 45, 79, 79, 79, 79, 79, 38, 53, 79, 79, 79, 79, 79, 79,
+ 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
+ 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79 },
+
+ /* index 6, Q25 */
+ { 32, 22, 20, 32, 48, 80,102,122, 24, 24, 28, 38, 52,116,120,110,
+ 28, 26, 32, 48, 80,114,138,112, 28, 34, 44, 58,102,174,160,124,
+ 36, 44, 74,112,136,218,206,154, 48, 70,110,128,162,208,226,184,
+ 98,128,156,174,206,242,240,202,144,184,190,196,224,200,206,198 },
+ { 34, 36, 48, 94,198,198,198,198, 36, 42, 52,132,198,198,198,198,
+ 48, 52,112,198,198,198,198,198, 94,132,198,198,198,198,198,198,
+ 198,198,198,198,198,198,198,198,198,198,198,198,198,198,198,198,
+ 198,198,198,198,198,198,198,198,198,198,198,198,198,198,198,198 },
+
+ /* index 7, Q95 */
+ { 2, 1, 1, 2, 2, 4, 5, 6, 1, 1, 1, 2, 3, 6, 6, 6,
+ 1, 1, 2, 2, 4, 6, 7, 6, 1, 2, 2, 3, 5, 9, 8, 6,
+ 2, 2, 4, 6, 7, 11, 10, 8, 2, 4, 6, 6, 8, 10, 11, 9,
+ 5, 6, 8, 9, 10, 12, 12, 10, 7, 9, 10, 10, 11, 10, 10, 10 },
+ { 2, 2, 2, 5, 10, 10, 10, 10, 2, 2, 3, 7, 10, 10, 10, 10,
+ 2, 3, 6, 10, 10, 10, 10, 10, 5, 7, 10, 10, 10, 10, 10, 10,
+ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
+ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 },
+
+ /* index 8, Q93 */
+ { 2, 2, 1, 2, 3, 6, 7, 9, 2, 2, 2, 3, 4, 8, 8, 8,
+ 2, 2, 2, 3, 6, 8, 10, 8, 2, 2, 3, 4, 7, 12, 11, 9,
+ 3, 3, 5, 8, 10, 15, 14, 11, 3, 5, 8, 9, 11, 15, 16, 13,
+ 7, 9, 11, 12, 14, 17, 17, 14, 10, 13, 13, 14, 16, 14, 14, 14 },
+ { 2, 3, 3, 7, 14, 14, 14, 14, 3, 3, 4, 9, 14, 14, 14, 14,
+ 3, 4, 8, 14, 14, 14, 14, 14, 7, 9, 14, 14, 14, 14, 14, 14,
+ 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+ 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14 }
+};
+#endif
+
+#endif /* SP5X_H */
diff --git a/src/libffmpeg/libavcodec/svq1.c b/src/libffmpeg/libavcodec/svq1.c
index e416f52da..bce799639 100644
--- a/src/libffmpeg/libavcodec/svq1.c
+++ b/src/libffmpeg/libavcodec/svq1.c
@@ -616,9 +616,9 @@ static int svq1_decode_frame_header (GetBitContext *bitbuf,MpegEncContext *s) {
printf ("embedded message: \"%s\"\n", (char *) msg);
}
- get_bits (bitbuf, 2);
- get_bits (bitbuf, 2);
- get_bits (bitbuf, 1);
+ skip_bits (bitbuf, 2);
+ skip_bits (bitbuf, 2);
+ skip_bits1 (bitbuf);
/* load frame size */
frame_size_code = get_bits (bitbuf, 3);
@@ -639,21 +639,21 @@ static int svq1_decode_frame_header (GetBitContext *bitbuf,MpegEncContext *s) {
/* unknown fields */
if (get_bits (bitbuf, 1) == 1) {
- get_bits (bitbuf, 1); /* use packet checksum if (1) */
- get_bits (bitbuf, 1); /* component checksums after image data if (1) */
+ skip_bits1 (bitbuf); /* use packet checksum if (1) */
+ skip_bits1 (bitbuf); /* component checksums after image data if (1) */
if (get_bits (bitbuf, 2) != 0)
return -1;
}
if (get_bits (bitbuf, 1) == 1) {
- get_bits (bitbuf, 1);
- get_bits (bitbuf, 4);
- get_bits (bitbuf, 1);
- get_bits (bitbuf, 2);
+ skip_bits1 (bitbuf);
+ skip_bits (bitbuf, 4);
+ skip_bits1 (bitbuf);
+ skip_bits (bitbuf, 2);
while (get_bits (bitbuf, 1) == 1) {
- get_bits (bitbuf, 8);
+ skip_bits (bitbuf, 8);
}
}
@@ -838,4 +838,5 @@ AVCodec svq1_decoder = {
svq1_decode_end,
svq1_decode_frame,
CODEC_CAP_DR1,
+ .flush= ff_mpeg_flush,
};
diff --git a/src/libffmpeg/libavcodec/svq1_cb.h b/src/libffmpeg/libavcodec/svq1_cb.h
index 77ee56dbb..14372a255 100644
--- a/src/libffmpeg/libavcodec/svq1_cb.h
+++ b/src/libffmpeg/libavcodec/svq1_cb.h
@@ -764,7 +764,7 @@ static const int8_t svq1_inter_codebook_8x8[6144] = {
};
/* list of codebooks for inter-coded vectors */
-static const int8_t* const svq1_inter_codebooks[4] = {
+static const uint8_t* const svq1_inter_codebooks[4] = {
svq1_inter_codebook_4x2, svq1_inter_codebook_4x4,
svq1_inter_codebook_8x4, svq1_inter_codebook_8x8
};
@@ -1506,7 +1506,7 @@ static const int8_t svq1_intra_codebook_8x8[6144] = {
};
/* list of codebooks for intra-coded vectors */
-static const int8_t* const svq1_intra_codebooks[4] = {
+static const uint8_t* const svq1_intra_codebooks[4] = {
svq1_intra_codebook_4x2, svq1_intra_codebook_4x4,
svq1_intra_codebook_8x4, svq1_intra_codebook_8x8
};
diff --git a/src/libffmpeg/libavcodec/utils.c b/src/libffmpeg/libavcodec/utils.c
index 3a30e734e..34051ad3a 100644
--- a/src/libffmpeg/libavcodec/utils.c
+++ b/src/libffmpeg/libavcodec/utils.c
@@ -127,10 +127,48 @@ typedef struct InternalBuffer{
#define INTERNAL_BUFFER_SIZE 32
+#define ALIGN(x, a) (((x)+(a)-1)&~((a)-1))
+
+void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){
+ int w_align= 1;
+ int h_align= 1;
+
+ switch(s->pix_fmt){
+ case PIX_FMT_YUV420P:
+ case PIX_FMT_YUV422:
+ case PIX_FMT_YUV422P:
+ case PIX_FMT_YUV444P:
+ case PIX_FMT_GRAY8:
+ case PIX_FMT_YUVJ420P:
+ case PIX_FMT_YUVJ422P:
+ case PIX_FMT_YUVJ444P:
+ w_align= 16; //FIXME check for non mpeg style codecs and use less alignment
+ h_align= 16;
+ break;
+ case PIX_FMT_YUV411P:
+ w_align=32;
+ h_align=8;
+ break;
+ case PIX_FMT_YUV410P:
+ if(s->codec_id == CODEC_ID_SVQ1){
+ w_align=64;
+ h_align=64;
+ }
+ break;
+ default:
+ w_align= 1;
+ h_align= 1;
+ break;
+ }
+
+ *width = ALIGN(*width , w_align);
+ *height= ALIGN(*height, h_align);
+}
+
int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
int i;
- const int width = s->width;
- const int height= s->height;
+ int w= s->width;
+ int h= s->height;
InternalBuffer *buf;
assert(pic->data[0]==NULL);
@@ -153,10 +191,11 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
pic->age= pic->coded_picture_number - buf->last_pic_num;
buf->last_pic_num= pic->coded_picture_number;
}else{
- int align, h_chroma_shift, v_chroma_shift;
- int w, h, pixel_size;
+ int h_chroma_shift, v_chroma_shift;
+ int s_align, 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:
@@ -173,13 +212,14 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
default:
pixel_size=1;
}
-
- if(s->codec_id==CODEC_ID_SVQ1) align=63;
- else align=15;
-
- w= (width +align)&~align;
- h= (height+align)&~align;
-
+
+ avcodec_align_dimensions(s, &w, &h);
+#if defined(ARCH_POWERPC) || defined(HAVE_MMI) //FIXME some cleaner check
+ s_align= 16;
+#else
+ s_align= 8;
+#endif
+
if(!(s->flags&CODEC_FLAG_EMU_EDGE)){
w+= EDGE_WIDTH*2;
h+= EDGE_WIDTH*2;
@@ -191,7 +231,7 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
const int h_shift= i==0 ? 0 : h_chroma_shift;
const int v_shift= i==0 ? 0 : v_chroma_shift;
- pic->linesize[i]= pixel_size*w>>h_shift;
+ pic->linesize[i]= ALIGN(pixel_size*w>>h_shift, s_align);
buf->base[i]= av_mallocz((pic->linesize[i]*h>>v_shift)+16); //FIXME 16
if(buf->base[i]==NULL) return -1;
@@ -200,7 +240,7 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
if(s->flags&CODEC_FLAG_EMU_EDGE)
buf->data[i] = buf->base[i];
else
- buf->data[i] = buf->base[i] + (pic->linesize[i]*EDGE_WIDTH>>v_shift) + (EDGE_WIDTH>>h_shift);
+ buf->data[i] = buf->base[i] + ALIGN((pic->linesize[i]*EDGE_WIDTH>>v_shift) + (EDGE_WIDTH>>h_shift), s_align);
}
pic->age= 256*256*256*64;
pic->type= FF_BUFFER_TYPE_INTERNAL;
@@ -220,7 +260,9 @@ void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){
InternalBuffer *buf, *last, temp;
assert(pic->type==FF_BUFFER_TYPE_INTERNAL);
+ assert(s->internal_buffer_count);
+ buf = NULL; /* avoids warning */
for(i=0; i<s->internal_buffer_count; i++){ //just 3-5 checks so is not worth to optimize
buf= &((InternalBuffer*)s->internal_buffer)[i];
if(buf->data[0] == pic->data[0])
@@ -270,6 +312,9 @@ void avcodec_get_context_defaults(AVCodecContext *s){
s->release_buffer= avcodec_default_release_buffer;
s->get_format= avcodec_default_get_format;
s->me_subpel_quality=8;
+ s->lmin= FF_QP2LAMBDA * s->qmin;
+ s->lmax= FF_QP2LAMBDA * s->qmax;
+ s->sample_aspect_ratio= (AVRational){0,1};
s->intra_quant_bias= FF_DEFAULT_QUANT_BIAS;
s->inter_quant_bias= FF_DEFAULT_QUANT_BIAS;
@@ -303,6 +348,9 @@ int avcodec_open(AVCodecContext *avctx, AVCodec *codec)
{
int ret;
+ if(avctx->codec)
+ return -1;
+
avctx->codec = codec;
avctx->codec_id = codec->id;
avctx->frame_number = 0;
@@ -469,6 +517,12 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
if (p) {
codec_name = p->name;
+ if (!encode && enc->codec_id == CODEC_ID_MP3) {
+ if (enc->sub_id == 2)
+ codec_name = "mp2";
+ else if (enc->sub_id == 1)
+ codec_name = "mp1";
+ }
} else if (enc->codec_name[0] != '\0') {
codec_name = enc->codec_name;
} else {
@@ -489,7 +543,7 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
case CODEC_TYPE_VIDEO:
snprintf(buf, buf_size,
"Video: %s%s",
- codec_name, enc->flags & CODEC_FLAG_HQ ? " (hq)" : "");
+ codec_name, enc->mb_decision ? " (hq)" : "");
if (enc->codec_id == CODEC_ID_RAWVIDEO) {
snprintf(buf + strlen(buf), buf_size - strlen(buf),
", %s",
@@ -590,38 +644,13 @@ void avcodec_init(void)
dsputil_static_init();
}
-/* this can be called after seeking and before trying to decode the next keyframe */
+/**
+ * Flush buffers, should be called when seeking or when swicthing to a different stream.
+ */
void avcodec_flush_buffers(AVCodecContext *avctx)
{
- int i;
- MpegEncContext *s = avctx->priv_data;
-
- switch(avctx->codec_id){
- case CODEC_ID_MPEG1VIDEO:
- case CODEC_ID_H263:
- case CODEC_ID_RV10:
-// case CODEC_ID_MJPEG:
-// case CODEC_ID_MJPEGB:
- case CODEC_ID_MPEG4:
- case CODEC_ID_MSMPEG4V1:
- case CODEC_ID_MSMPEG4V2:
- case CODEC_ID_MSMPEG4V3:
- case CODEC_ID_WMV1:
- case CODEC_ID_WMV2:
- case CODEC_ID_H263P:
- case CODEC_ID_H263I:
- case CODEC_ID_SVQ1:
- for(i=0; i<MAX_PICTURE_COUNT; i++){
- if(s->picture[i].data[0] && ( s->picture[i].type == FF_BUFFER_TYPE_INTERNAL
- || s->picture[i].type == FF_BUFFER_TYPE_USER))
- avctx->release_buffer(avctx, (AVFrame*)&s->picture[i]);
- }
- s->last_picture_ptr = s->next_picture_ptr = NULL;
- break;
- default:
- //FIXME
- break;
- }
+ if(avctx->codec->flush)
+ avctx->codec->flush(avctx);
}
void avcodec_default_free_buffers(AVCodecContext *s){
@@ -655,7 +684,7 @@ char av_get_pict_type_char(int pict_type){
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;
+ int64_t gcd;
assert(den != 0);
@@ -669,22 +698,34 @@ int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max)
sign= 1;
}
- for(;;){ //note is executed 1 or 2 times
- gcd = ff_gcd(nom, den);
- nom /= gcd;
- den /= gcd;
-
- larger= FFMAX(nom, den);
+ gcd = ff_gcd(nom, den);
+ nom /= gcd;
+ den /= gcd;
- if(larger > max){
- int64_t div= (larger + max - 1) / max;
- nom = (nom + div/2)/div;
- den = (den + div/2)/div;
- exact=0;
- }else
- break;
+ if(nom > max || den > max){
+ AVRational a0={0,1}, a1={1,0};
+ exact=0;
+
+ for(;;){
+ int64_t x= nom / den;
+ int64_t a2n= x*a1.num + a0.num;
+ int64_t a2d= x*a1.den + a0.den;
+
+ if(a2n > max || a2d > max) break;
+
+ nom %= den;
+
+ a0= a1;
+ a1= (AVRational){a2n, a2d};
+ if(nom==0) break;
+ x= nom; nom=den; den=x;
+ }
+ nom= a1.num;
+ den= a1.den;
}
+ assert(ff_gcd(nom, den) == 1);
+
if(sign) nom= -nom;
*dst_nom = nom;
diff --git a/src/libffmpeg/libavcodec/vcr1.c b/src/libffmpeg/libavcodec/vcr1.c
new file mode 100644
index 000000000..4905c703f
--- /dev/null
+++ b/src/libffmpeg/libavcodec/vcr1.c
@@ -0,0 +1,200 @@
+/*
+ * ATI VCR1 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 vcr1.c
+ * ati vcr1 codec.
+ */
+
+#include "avcodec.h"
+#include "mpegvideo.h"
+
+//#undef NDEBUG
+//#include <assert.h>
+
+typedef struct VCR1Context{
+ AVCodecContext *avctx;
+ AVFrame picture;
+ int delta[16];
+ int offset[4];
+} VCR1Context;
+
+static int decode_frame(AVCodecContext *avctx,
+ void *data, int *data_size,
+ uint8_t *buf, int buf_size)
+{
+ VCR1Context * const a = avctx->priv_data;
+ AVFrame *picture = data;
+ AVFrame * const p= (AVFrame*)&a->picture;
+ uint8_t *bytestream= buf;
+ int i, x, y;
+
+ *data_size = 0;
+
+ /* special case for last picture */
+ if (buf_size == 0) {
+ return 0;
+ }
+
+ if(p->data[0])
+ avctx->release_buffer(avctx, p);
+
+ p->reference= 0;
+ if(avctx->get_buffer(avctx, p) < 0){
+ fprintf(stderr, "get_buffer() failed\n");
+ return -1;
+ }
+ p->pict_type= I_TYPE;
+ p->key_frame= 1;
+
+ for(i=0; i<16; i++){
+ a->delta[i]= *(bytestream++);
+ bytestream++;
+ }
+
+ for(y=0; y<avctx->height; y++){
+ int offset;
+ uint8_t *luma= &a->picture.data[0][ y*a->picture.linesize[0] ];
+
+ if((y&3) == 0){
+ uint8_t *cb= &a->picture.data[1][ (y>>2)*a->picture.linesize[1] ];
+ uint8_t *cr= &a->picture.data[2][ (y>>2)*a->picture.linesize[2] ];
+
+ for(i=0; i<4; i++)
+ a->offset[i]= *(bytestream++);
+
+ offset= a->offset[0] - a->delta[ bytestream[2]&0xF ];
+ for(x=0; x<avctx->width; x+=4){
+ luma[0]=( offset += a->delta[ bytestream[2]&0xF ]);
+ luma[1]=( offset += a->delta[ bytestream[2]>>4 ]);
+ luma[2]=( offset += a->delta[ bytestream[0]&0xF ]);
+ luma[3]=( offset += a->delta[ bytestream[0]>>4 ]);
+ luma += 4;
+
+ *(cb++) = bytestream[3];
+ *(cr++) = bytestream[1];
+
+ bytestream+= 4;
+ }
+ }else{
+ offset= a->offset[y&3] - a->delta[ bytestream[2]&0xF ];
+
+ for(x=0; x<avctx->width; x+=8){
+ luma[0]=( offset += a->delta[ bytestream[2]&0xF ]);
+ luma[1]=( offset += a->delta[ bytestream[2]>>4 ]);
+ luma[2]=( offset += a->delta[ bytestream[3]&0xF ]);
+ luma[3]=( offset += a->delta[ bytestream[3]>>4 ]);
+ luma[4]=( offset += a->delta[ bytestream[0]&0xF ]);
+ luma[5]=( offset += a->delta[ bytestream[0]>>4 ]);
+ luma[6]=( offset += a->delta[ bytestream[1]&0xF ]);
+ luma[7]=( offset += a->delta[ bytestream[1]>>4 ]);
+ luma += 8;
+ bytestream+= 4;
+ }
+ }
+ }
+
+ *picture= *(AVFrame*)&a->picture;
+ *data_size = sizeof(AVPicture);
+
+ emms_c();
+
+ return buf_size;
+}
+
+#if 0
+static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){
+ VCR1Context * const a = avctx->priv_data;
+ AVFrame *pict = data;
+ AVFrame * const p= (AVFrame*)&a->picture;
+ int size;
+ int mb_x, mb_y;
+
+ *p = *pict;
+ p->pict_type= I_TYPE;
+ p->key_frame= 1;
+
+ emms_c();
+
+ align_put_bits(&a->pb);
+ while(get_bit_count(&a->pb)&31)
+ put_bits(&a->pb, 8, 0);
+
+ size= get_bit_count(&a->pb)/32;
+
+ return size*4;
+}
+#endif
+
+static void common_init(AVCodecContext *avctx){
+ VCR1Context * const a = avctx->priv_data;
+
+ avctx->coded_frame= (AVFrame*)&a->picture;
+ a->avctx= avctx;
+}
+
+static int decode_init(AVCodecContext *avctx){
+
+ common_init(avctx);
+
+ avctx->pix_fmt= PIX_FMT_YUV410P;
+
+ return 0;
+}
+
+static int encode_init(AVCodecContext *avctx){
+
+ common_init(avctx);
+
+ return 0;
+}
+
+static int decode_end(AVCodecContext *avctx){
+
+ avcodec_default_free_buffers(avctx);
+
+ return 0;
+}
+
+AVCodec vcr1_decoder = {
+ "vcr1",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_VCR1,
+ sizeof(VCR1Context),
+ decode_init,
+ NULL,
+ decode_end,
+ decode_frame,
+ CODEC_CAP_DR1,
+};
+#if 0
+#ifdef CONFIG_ENCODERS
+
+AVCodec vcr1_encoder = {
+ "vcr1",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_VCR1,
+ sizeof(VCR1Context),
+ encode_init,
+ encode_frame,
+ //encode_end,
+};
+
+#endif //CONFIG_ENCODERS
+#endif
diff --git a/src/libffmpeg/libavcodec/vp3.c b/src/libffmpeg/libavcodec/vp3.c
index 1f87086c2..c72c7fc16 100644
--- a/src/libffmpeg/libavcodec/vp3.c
+++ b/src/libffmpeg/libavcodec/vp3.c
@@ -17,6 +17,10 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* VP3 Video Decoder by Mike Melanson (melanson@pcisys.net)
+ * For more information about the VP3 coding process, visit:
+ * http://www.pcisys.net/~melanson/codecs/
+ *
+ * Theora decoder by Alex Beregszaszi
*
*/
@@ -211,6 +215,7 @@ static int ModeAlphabet[7][CODING_MODE_COUNT] =
typedef struct Vp3DecodeContext {
AVCodecContext *avctx;
+ int theora, theora_tables;
int width, height;
AVFrame golden_frame;
AVFrame last_frame;
@@ -243,6 +248,13 @@ typedef struct Vp3DecodeContext {
Vp3Fragment *all_fragments;
int u_fragment_start;
int v_fragment_start;
+
+ /* tables */
+ uint16_t coded_dc_scale_factor[64];
+ uint32_t coded_quality_threshold[64];
+ uint16_t coded_intra_y_dequant[64];
+ uint16_t coded_intra_c_dequant[64];
+ uint16_t coded_inter_dequant[64];
/* this is a list of indices into the all_fragments array indicating
* which of the fragments are coded */
@@ -285,9 +297,312 @@ typedef struct Vp3DecodeContext {
int last_coded_y_fragment;
int last_coded_c_fragment;
+ uint8_t edge_emu_buffer[9*2048]; //FIXME dynamic alloc
+ uint8_t qscale_table[2048]; //FIXME dynamic alloc (width+15)/16
} Vp3DecodeContext;
/************************************************************************
+ * VP3 I/DCT
+ ************************************************************************/
+
+#define IdctAdjustBeforeShift 8
+#define xC1S7 64277
+#define xC2S6 60547
+#define xC3S5 54491
+#define xC4S4 46341
+#define xC5S3 36410
+#define xC6S2 25080
+#define xC7S1 12785
+
+void vp3_idct_c(int16_t *input_data, int16_t *dequant_matrix,
+ int16_t *output_data)
+{
+ int32_t intermediate_data[64];
+ int32_t *ip = intermediate_data;
+ int16_t *op = output_data;
+
+ int32_t A_, B_, C_, D_, _Ad, _Bd, _Cd, _Dd, E_, F_, G_, H_;
+ int32_t _Ed, _Gd, _Add, _Bdd, _Fd, _Hd;
+ int32_t t1, t2;
+
+ int i, j;
+
+ debug_idct("raw coefficient block:\n");
+ for (i = 0; i < 8; i++) {
+ for (j = 0; j < 8; j++) {
+ debug_idct(" %5d", input_data[i * 8 + j]);
+ }
+ debug_idct("\n");
+ }
+ debug_idct("\n");
+
+ for (i = 0; i < 64; i++) {
+ j = dezigzag_index[i];
+ intermediate_data[j] = dequant_matrix[i] * input_data[i];
+ }
+
+ debug_idct("dequantized block:\n");
+ for (i = 0; i < 8; i++) {
+ for (j = 0; j < 8; j++) {
+ debug_idct(" %5d", intermediate_data[i * 8 + j]);
+ }
+ debug_idct("\n");
+ }
+ debug_idct("\n");
+
+ /* Inverse DCT on the rows now */
+ for (i = 0; i < 8; i++) {
+ /* Check for non-zero values */
+ if ( ip[0] | ip[1] | ip[2] | ip[3] | ip[4] | ip[5] | ip[6] | ip[7] ) {
+ t1 = (int32_t)(xC1S7 * ip[1]);
+ t2 = (int32_t)(xC7S1 * ip[7]);
+ t1 >>= 16;
+ t2 >>= 16;
+ A_ = t1 + t2;
+
+ t1 = (int32_t)(xC7S1 * ip[1]);
+ t2 = (int32_t)(xC1S7 * ip[7]);
+ t1 >>= 16;
+ t2 >>= 16;
+ B_ = t1 - t2;
+
+ t1 = (int32_t)(xC3S5 * ip[3]);
+ t2 = (int32_t)(xC5S3 * ip[5]);
+ t1 >>= 16;
+ t2 >>= 16;
+ C_ = t1 + t2;
+
+ t1 = (int32_t)(xC3S5 * ip[5]);
+ t2 = (int32_t)(xC5S3 * ip[3]);
+ t1 >>= 16;
+ t2 >>= 16;
+ D_ = t1 - t2;
+
+
+ t1 = (int32_t)(xC4S4 * (A_ - C_));
+ t1 >>= 16;
+ _Ad = t1;
+
+ t1 = (int32_t)(xC4S4 * (B_ - D_));
+ t1 >>= 16;
+ _Bd = t1;
+
+
+ _Cd = A_ + C_;
+ _Dd = B_ + D_;
+
+ t1 = (int32_t)(xC4S4 * (ip[0] + ip[4]));
+ t1 >>= 16;
+ E_ = t1;
+
+ t1 = (int32_t)(xC4S4 * (ip[0] - ip[4]));
+ t1 >>= 16;
+ F_ = t1;
+
+ t1 = (int32_t)(xC2S6 * ip[2]);
+ t2 = (int32_t)(xC6S2 * ip[6]);
+ t1 >>= 16;
+ t2 >>= 16;
+ G_ = t1 + t2;
+
+ t1 = (int32_t)(xC6S2 * ip[2]);
+ t2 = (int32_t)(xC2S6 * ip[6]);
+ t1 >>= 16;
+ t2 >>= 16;
+ H_ = t1 - t2;
+
+
+ _Ed = E_ - G_;
+ _Gd = E_ + G_;
+
+ _Add = F_ + _Ad;
+ _Bdd = _Bd - H_;
+
+ _Fd = F_ - _Ad;
+ _Hd = _Bd + H_;
+
+ /* Final sequence of operations over-write original inputs. */
+ ip[0] = (int16_t)((_Gd + _Cd ) >> 0);
+ ip[7] = (int16_t)((_Gd - _Cd ) >> 0);
+
+ ip[1] = (int16_t)((_Add + _Hd ) >> 0);
+ ip[2] = (int16_t)((_Add - _Hd ) >> 0);
+
+ ip[3] = (int16_t)((_Ed + _Dd ) >> 0);
+ ip[4] = (int16_t)((_Ed - _Dd ) >> 0);
+
+ ip[5] = (int16_t)((_Fd + _Bdd ) >> 0);
+ ip[6] = (int16_t)((_Fd - _Bdd ) >> 0);
+
+ }
+
+ ip += 8; /* next row */
+ }
+
+ ip = intermediate_data;
+
+ for ( i = 0; i < 8; i++) {
+ /* Check for non-zero values (bitwise or faster than ||) */
+ if ( ip[0 * 8] | ip[1 * 8] | ip[2 * 8] | ip[3 * 8] |
+ ip[4 * 8] | ip[5 * 8] | ip[6 * 8] | ip[7 * 8] ) {
+
+ t1 = (int32_t)(xC1S7 * ip[1*8]);
+ t2 = (int32_t)(xC7S1 * ip[7*8]);
+ t1 >>= 16;
+ t2 >>= 16;
+ A_ = t1 + t2;
+
+ t1 = (int32_t)(xC7S1 * ip[1*8]);
+ t2 = (int32_t)(xC1S7 * ip[7*8]);
+ t1 >>= 16;
+ t2 >>= 16;
+ B_ = t1 - t2;
+
+ t1 = (int32_t)(xC3S5 * ip[3*8]);
+ t2 = (int32_t)(xC5S3 * ip[5*8]);
+ t1 >>= 16;
+ t2 >>= 16;
+ C_ = t1 + t2;
+
+ t1 = (int32_t)(xC3S5 * ip[5*8]);
+ t2 = (int32_t)(xC5S3 * ip[3*8]);
+ t1 >>= 16;
+ t2 >>= 16;
+ D_ = t1 - t2;
+
+
+ t1 = (int32_t)(xC4S4 * (A_ - C_));
+ t1 >>= 16;
+ _Ad = t1;
+
+ t1 = (int32_t)(xC4S4 * (B_ - D_));
+ t1 >>= 16;
+ _Bd = t1;
+
+
+ _Cd = A_ + C_;
+ _Dd = B_ + D_;
+
+ t1 = (int32_t)(xC4S4 * (ip[0*8] + ip[4*8]));
+ t1 >>= 16;
+ E_ = t1;
+
+ t1 = (int32_t)(xC4S4 * (ip[0*8] - ip[4*8]));
+ t1 >>= 16;
+ F_ = t1;
+
+ t1 = (int32_t)(xC2S6 * ip[2*8]);
+ t2 = (int32_t)(xC6S2 * ip[6*8]);
+ t1 >>= 16;
+ t2 >>= 16;
+ G_ = t1 + t2;
+
+ t1 = (int32_t)(xC6S2 * ip[2*8]);
+ t2 = (int32_t)(xC2S6 * ip[6*8]);
+ t1 >>= 16;
+ t2 >>= 16;
+ H_ = t1 - t2;
+
+
+ _Ed = E_ - G_;
+ _Gd = E_ + G_;
+
+ _Add = F_ + _Ad;
+ _Bdd = _Bd - H_;
+
+ _Fd = F_ - _Ad;
+ _Hd = _Bd + H_;
+
+ _Gd += IdctAdjustBeforeShift;
+ _Add += IdctAdjustBeforeShift;
+ _Ed += IdctAdjustBeforeShift;
+ _Fd += IdctAdjustBeforeShift;
+
+ /* Final sequence of operations over-write original inputs. */
+ op[0*8] = (int16_t)((_Gd + _Cd ) >> 4);
+ op[7*8] = (int16_t)((_Gd - _Cd ) >> 4);
+
+ op[1*8] = (int16_t)((_Add + _Hd ) >> 4);
+ op[2*8] = (int16_t)((_Add - _Hd ) >> 4);
+
+ op[3*8] = (int16_t)((_Ed + _Dd ) >> 4);
+ op[4*8] = (int16_t)((_Ed - _Dd ) >> 4);
+
+ op[5*8] = (int16_t)((_Fd + _Bdd ) >> 4);
+ op[6*8] = (int16_t)((_Fd - _Bdd ) >> 4);
+
+ } else {
+
+ op[0*8] = 0;
+ op[7*8] = 0;
+ op[1*8] = 0;
+ op[2*8] = 0;
+ op[3*8] = 0;
+ op[4*8] = 0;
+ op[5*8] = 0;
+ op[6*8] = 0;
+ }
+
+ ip++; /* next column */
+ op++;
+ }
+}
+
+void vp3_idct_put(int16_t *input_data, int16_t *dequant_matrix,
+ uint8_t *dest, int stride)
+{
+ int16_t transformed_data[64];
+ int16_t *op;
+ int i, j;
+
+ vp3_idct_c(input_data, dequant_matrix, transformed_data);
+
+ /* place in final output */
+ op = transformed_data;
+ for (i = 0; i < 8; i++) {
+ for (j = 0; j < 8; j++) {
+ if (*op < -128)
+ *dest = 0;
+ else if (*op > 127)
+ *dest = 255;
+ else
+ *dest = (uint8_t)(*op + 128);
+ op++;
+ dest++;
+ }
+ dest += (stride - 8);
+ }
+}
+
+void vp3_idct_add(int16_t *input_data, int16_t *dequant_matrix,
+ uint8_t *dest, int stride)
+{
+ int16_t transformed_data[64];
+ int16_t *op;
+ int i, j;
+ int16_t sample;
+
+ vp3_idct_c(input_data, dequant_matrix, transformed_data);
+
+ /* place in final output */
+ op = transformed_data;
+ for (i = 0; i < 8; i++) {
+ for (j = 0; j < 8; j++) {
+ sample = *dest + *op;
+ if (sample < 0)
+ *dest = 0;
+ else if (sample > 255)
+ *dest = 255;
+ else
+ *dest = (uint8_t)(sample & 0xFF);
+ op++;
+ dest++;
+ }
+ dest += (stride - 8);
+ }
+}
+
+/************************************************************************
* VP3 specific functions
************************************************************************/
@@ -825,8 +1140,8 @@ s->all_fragments[i].motion_y = 0xbeef;
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 quality_scale = s->coded_quality_threshold[s->quality_index];
+ int dc_scale_factor = s->coded_dc_scale_factor[s->quality_index];
int i, j;
debug_vp3(" vp3: initializing dequantization tables\n");
@@ -843,20 +1158,20 @@ static void init_dequantizer(Vp3DecodeContext *s)
*
* Then, saturate the result to a lower limit of MIN_DEQUANT_VAL.
*/
-#define SCALER 1
+#define SCALER 4
/* scale DC quantizers */
- s->intra_y_dequant[0] = vp31_intra_y_dequant[0] * dc_scale_factor / 100;
+ s->intra_y_dequant[0] = s->coded_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;
+ s->intra_c_dequant[0] = s->coded_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;
+ s->inter_dequant[0] = s->coded_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;
@@ -867,21 +1182,23 @@ static void init_dequantizer(Vp3DecodeContext *s)
j = zigzag_index[i];
- s->intra_y_dequant[j] = vp31_intra_y_dequant[i] * quality_scale / 100;
+ s->intra_y_dequant[j] = s->coded_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;
+ s->intra_c_dequant[j] = s->coded_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;
+ s->inter_dequant[j] = s->coded_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;
}
+
+ memset(s->qscale_table, (FFMAX(s->intra_y_dequant[1], s->intra_c_dequant[1])+8)/16, 512); //FIXME finetune
/* print debug information as requested */
debug_dequantizers("intra Y dequantizers:\n");
@@ -2029,10 +2346,7 @@ static void render_fragments(Vp3DecodeContext *s,
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;
@@ -2040,7 +2354,7 @@ static void render_fragments(Vp3DecodeContext *s,
int motion_x, motion_y;
int upper_motion_limit, lower_motion_limit;
int motion_halfpel_index;
- unsigned int motion_source;
+ uint8_t *motion_source;
debug_vp3(" vp3: rendering final fragments for %s\n",
(plane == 0) ? "Y plane" : (plane == 1) ? "U plane" : "V plane");
@@ -2086,63 +2400,55 @@ static void render_fragments(Vp3DecodeContext *s,
/* transform if this block was coded */
if (s->all_fragments[i].coding_method != MODE_COPY) {
- motion_source = s->all_fragments[i].first_pixel;
+ if ((s->all_fragments[i].coding_method == MODE_USING_GOLDEN) ||
+ (s->all_fragments[i].coding_method == MODE_GOLDEN_MV))
+ motion_source= golden_plane;
+ else
+ motion_source= last_plane;
+
+ 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)) {
+ int src_x, src_y;
motion_x = s->all_fragments[i].motion_x;
motion_y = s->all_fragments[i].motion_y;
+ if(plane){
+ motion_x= (motion_x>>1) | (motion_x&1);
+ motion_y= (motion_y>>1) | (motion_y&1);
+ }
+
+ src_x= (motion_x>>1) + x;
+ src_y= (motion_y>>1) + 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_halfpel_index = motion_x & 0x01;
+ motion_source += (motion_x >> 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);
- }
+ motion_halfpel_index |= (motion_y & 0x01) << 1;
+ motion_source += ((motion_y >> 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;
+ if(src_x<0 || src_y<0 || src_x + 9 >= width || src_y + 9 >= height){
+ uint8_t *temp= s->edge_emu_buffer;
+ if(stride<0) temp -= 9*stride;
+
+ ff_emulated_edge_mc(temp, motion_source, stride, 9, 9, src_x, src_y, width, height);
+ motion_source= temp;
}
}
/* 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](
+ s->dsp.put_no_rnd_pixels_tab[1][motion_halfpel_index](
output_plane + s->all_fragments[i].first_pixel,
- last_plane + motion_source,
+ motion_source,
stride, 8);
}
@@ -2150,34 +2456,16 @@ printf (" help! got beefy vector! (%X, %X)\n", motion_x, motion_y);
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(
+ vp3_idct_put(s->all_fragments[i].coeffs, dequantizer,
output_plane + s->all_fragments[i].first_pixel,
- stride, dequant_block_permuted);
+ stride);
} else {
- s->dsp.idct_add(
+ vp3_idct_add(s->all_fragments[i].coeffs, dequantizer,
output_plane + s->all_fragments[i].first_pixel,
- stride, dequant_block_permuted);
+ stride);
}
debug_idct("block after idct_%s():\n",
@@ -2336,6 +2624,20 @@ static int vp3_decode_init(AVCodecContext *avctx)
s->coded_fragment_list = av_malloc(s->fragment_count * sizeof(int));
s->pixel_addresses_inited = 0;
+ if (!s->theora_tables)
+ {
+ for (i = 0; i < 64; i++)
+ s->coded_dc_scale_factor[i] = vp31_dc_scale_factor[i];
+ for (i = 0; i < 64; i++)
+ s->coded_quality_threshold[i] = vp31_quality_threshold[i];
+ for (i = 0; i < 64; i++)
+ s->coded_intra_y_dequant[i] = vp31_intra_y_dequant[i];
+ for (i = 0; i < 64; i++)
+ s->coded_intra_c_dequant[i] = vp31_intra_c_dequant[i];
+ for (i = 0; i < 64; i++)
+ s->coded_inter_dequant[i] = vp31_inter_dequant[i];
+ }
+
/* init VLC tables */
for (i = 0; i < 16; i++) {
@@ -2382,8 +2684,6 @@ static int vp3_decode_init(AVCodecContext *avctx)
s->golden_frame.data[i] = NULL;
}
-avctx->flags |= CODEC_FLAG_GRAY;
-
return 0;
}
@@ -2401,29 +2701,39 @@ static int vp3_decode_frame(AVCodecContext *avctx,
*data_size = 0;
init_get_bits(&gb, buf, buf_size * 8);
+
+ if (s->theora && get_bits1(&gb))
+ {
+ printf("Theora: bad frame indicator\n");
+ return -1;
+ }
- s->keyframe = get_bits(&gb, 1);
- s->keyframe ^= 1;
- skip_bits(&gb, 1);
+ s->keyframe = !get_bits1(&gb);
+ if (s->theora && s->keyframe)
+ {
+ if (get_bits1(&gb))
+ printf("Theora: warning, unsupported keyframe coding type?!\n");
+ skip_bits(&gb, 2); /* reserved? */
+ }
+ else
+ 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);
+ debug_vp3(" VP3 %sframe #%d: Q index = %d\n",
+ s->keyframe?"key":"", counter, s->quality_index);
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->theora) 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);
+ s->last_frame= s->golden_frame; /* ensure that we catch any access to this released frame */
} else {
if (s->golden_frame.data[0])
avctx->release_buffer(avctx, &s->golden_frame);
@@ -2431,7 +2741,7 @@ printf (" frame #%d\n", counter);
avctx->release_buffer(avctx, &s->last_frame);
}
- s->golden_frame.reference = 0;
+ s->golden_frame.reference = 3;
if(avctx->get_buffer(avctx, &s->golden_frame) < 0) {
printf("vp3: get_buffer() failed\n");
return -1;
@@ -2445,17 +2755,17 @@ printf (" frame #%d\n", counter);
vp3_calculate_pixel_addresses(s);
} else {
-
- debug_vp3("\n");
-
/* allocate a new current frame */
- s->current_frame.reference = 0;
+ s->current_frame.reference = 3;
if(avctx->get_buffer(avctx, &s->current_frame) < 0) {
printf("vp3: get_buffer() failed\n");
return -1;
}
}
+ s->current_frame.qscale_table= s->qscale_table; //FIXME allocate individual tables per AVFrame
+ s->current_frame.qstride= 0;
+
init_frame(s, &gb);
#if KEYFRAMES_ONLY
@@ -2510,6 +2820,7 @@ if (!s->keyframe) {
/* shuffle frames (last = current) */
memcpy(&s->last_frame, &s->current_frame, sizeof(AVFrame));
+ s->current_frame.data[0]= NULL; /* ensure that we catch any access to this released frame */
return buf_size;
}
@@ -2527,9 +2838,9 @@ static int vp3_decode_end(AVCodecContext *avctx)
av_free(s->superblock_macroblocks);
av_free(s->macroblock_fragments);
av_free(s->macroblock_coding);
-
+
/* release all frames */
- if (s->golden_frame.data[0])
+ if (s->golden_frame.data[0] && s->golden_frame.data[0] != s->last_frame.data[0])
avctx->release_buffer(avctx, &s->golden_frame);
if (s->last_frame.data[0])
avctx->release_buffer(avctx, &s->last_frame);
@@ -2539,6 +2850,133 @@ static int vp3_decode_end(AVCodecContext *avctx)
return 0;
}
+/* current version is 3.2.0 */
+
+static int theora_decode_header(AVCodecContext *avctx, GetBitContext gb)
+{
+ Vp3DecodeContext *s = avctx->priv_data;
+
+ skip_bits(&gb, 8); /* version major */
+ skip_bits(&gb, 8); /* version minor */
+ skip_bits(&gb, 8); /* version micro */
+
+ s->width = get_bits(&gb, 16) << 4;
+ s->height = get_bits(&gb, 16) << 4;
+
+ skip_bits(&gb, 24); /* frame width */
+ skip_bits(&gb, 24); /* frame height */
+
+ skip_bits(&gb, 8); /* offset x */
+ skip_bits(&gb, 8); /* offset y */
+
+ skip_bits(&gb, 32); /* fps numerator */
+ skip_bits(&gb, 32); /* fps denumerator */
+ skip_bits(&gb, 24); /* aspect numerator */
+ skip_bits(&gb, 24); /* aspect denumerator */
+
+ skip_bits(&gb, 5); /* keyframe frequency force */
+ skip_bits(&gb, 8); /* colorspace */
+ skip_bits(&gb, 24); /* bitrate */
+
+ skip_bits(&gb, 6); /* last(?) quality index */
+
+// align_get_bits(&gb);
+
+ avctx->width = s->width;
+ avctx->height = s->height;
+
+ vp3_decode_init(avctx);
+
+ return 0;
+}
+
+static int theora_decode_comments(AVCodecContext *avctx, GetBitContext gb)
+{
+ int nb_comments, i, tmp;
+
+ tmp = get_bits(&gb, 32);
+ while(tmp-=8)
+ skip_bits(&gb, 8);
+
+ nb_comments = get_bits(&gb, 32);
+ for (i = 0; i < nb_comments; i++)
+ {
+ tmp = get_bits(&gb, 32);
+ while(tmp-=8)
+ skip_bits(&gb, 8);
+ }
+
+ return 0;
+}
+
+static int theora_decode_tables(AVCodecContext *avctx, GetBitContext gb)
+{
+ Vp3DecodeContext *s = avctx->priv_data;
+ int i;
+
+ /* quality threshold table */
+ for (i = 0; i < 64; i++)
+ s->coded_quality_threshold[i] = get_bits(&gb, 16);
+
+ /* dc scale factor table */
+ for (i = 0; i < 64; i++)
+ s->coded_dc_scale_factor[i] = get_bits(&gb, 16);
+
+ /* y coeffs */
+ for (i = 0; i < 64; i++)
+ s->coded_intra_y_dequant[i] = get_bits(&gb, 8);
+
+ /* uv coeffs */
+ for (i = 0; i < 64; i++)
+ s->coded_intra_c_dequant[i] = get_bits(&gb, 8);
+
+ /* inter coeffs */
+ for (i = 0; i < 64; i++)
+ s->coded_inter_dequant[i] = get_bits(&gb, 8);
+
+ s->theora_tables = 1;
+
+ return 0;
+}
+
+static int theora_decode_init(AVCodecContext *avctx)
+{
+ Vp3DecodeContext *s = avctx->priv_data;
+ GetBitContext gb;
+ int ptype;
+
+ s->theora = 1;
+
+ if (!avctx->extradata_size)
+ return -1;
+
+ init_get_bits(&gb, avctx->extradata, avctx->extradata_size);
+
+ ptype = get_bits(&gb, 8);
+ debug_vp3("Theora headerpacket type: %x\n", ptype);
+
+ if (!(ptype & 0x80))
+ return -1;
+
+ skip_bits(&gb, 6*8); /* "theora" */
+
+ switch(ptype)
+ {
+ case 0x80:
+ theora_decode_header(avctx, gb);
+ vp3_decode_init(avctx);
+ break;
+ case 0x81:
+ theora_decode_comments(avctx, gb);
+ break;
+ case 0x82:
+ theora_decode_tables(avctx, gb);
+ break;
+ }
+
+ return 0;
+}
+
AVCodec vp3_decoder = {
"vp3",
CODEC_TYPE_VIDEO,
@@ -2551,3 +2989,16 @@ AVCodec vp3_decoder = {
0,
NULL
};
+
+AVCodec theora_decoder = {
+ "theora",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_THEORA,
+ sizeof(Vp3DecodeContext),
+ theora_decode_init,
+ NULL,
+ vp3_decode_end,
+ vp3_decode_frame,
+ 0,
+ NULL
+};
diff --git a/src/libffmpeg/libavcodec/vqavideo.c b/src/libffmpeg/libavcodec/vqavideo.c
new file mode 100644
index 000000000..174116dbc
--- /dev/null
+++ b/src/libffmpeg/libavcodec/vqavideo.c
@@ -0,0 +1,618 @@
+/*
+ * Westwood Studios VQA Video Decoder
+ * 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
+ *
+ */
+
+/**
+ * @file vqavideo.c
+ * VQA Video Decoder by Mike Melanson (melanson@pcisys.net)
+ * For more information about the RPZA format, visit:
+ * http://www.pcisys.net/~melanson/codecs/
+ *
+ * The VQA video decoder outputs PAL8 or RGB555 colorspace data, depending
+ * on the type of data in the file.
+ *
+ * This decoder needs the 42-byte VQHD header from the beginning
+ * of the VQA file passed through the extradata field. The VQHD header
+ * is laid out as:
+ *
+ * bytes 0-3 chunk fourcc: 'VQHD'
+ * bytes 4-7 chunk size in big-endian format, should be 0x0000002A
+ * bytes 8-49 VQHD chunk data
+ *
+ * Bytes 8-49 are what this decoder expects to see.
+ *
+ * Briefly, VQA is a vector quantized animation format that operates in a
+ * VGA palettized colorspace. It operates on pixel vectors (blocks)
+ * of either 4x2 or 4x4 in size. Compressed VQA chunks can contain vector
+ * codebooks, palette information, and code maps for rendering vectors onto
+ * frames. Any of these components can also be compressed with a run-length
+ * encoding (RLE) algorithm commonly referred to as "format80".
+ *
+ * VQA takes a novel approach to rate control. Each group of n frames
+ * (usually, n = 8) relies on a different vector codebook. Rather than
+ * transporting an entire codebook every 8th frame, the new codebook is
+ * broken up into 8 pieces and sent along with the compressed video chunks
+ * for each of the 8 frames preceding the 8 frames which require the
+ * codebook. A full codebook is also sent on the very first frame of a
+ * file. This is an interesting technique, although it makes random file
+ * seeking difficult despite the fact that the frames are all intracoded.
+ *
+ * V1,2 VQA uses 12-bit codebook indices. If the 12-bit indices were
+ * packed into bytes and then RLE compressed, bytewise, the results would
+ * be poor. That is why the coding method divides each index into 2 parts,
+ * the top 4 bits and the bottom 8 bits, then RL encodes the 4-bit pieces
+ * together and the 8-bit pieces together. If most of the vectors are
+ * clustered into one group of 256 vectors, most of the 4-bit index pieces
+ * should be the same.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "common.h"
+#include "avcodec.h"
+#include "dsputil.h"
+
+#define PALETTE_COUNT 256
+#define VQA_HEADER_SIZE 0x2A
+#define CHUNK_PREAMBLE_SIZE 8
+
+/* allocate the maximum vector space, regardless of the file version:
+ * (0xFF00 codebook vectors + 0x100 solid pixel vectors) * (4x4 pixels/block) */
+#define MAX_CODEBOOK_VECTORS 0xFF00
+#define SOLID_PIXEL_VECTORS 0x100
+#define MAX_VECTORS (MAX_CODEBOOK_VECTORS + SOLID_PIXEL_VECTORS)
+#define MAX_CODEBOOK_SIZE (MAX_VECTORS * 4 * 4)
+
+#define LE_16(x) ((((uint8_t*)(x))[1] << 8) | ((uint8_t*)(x))[0])
+#define BE_16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1])
+#define BE_32(x) ((((uint8_t*)(x))[0] << 24) | \
+ (((uint8_t*)(x))[1] << 16) | \
+ (((uint8_t*)(x))[2] << 8) | \
+ ((uint8_t*)(x))[3])
+
+#define FOURCC_TAG( ch0, ch1, ch2, ch3 ) \
+ ( (long)(unsigned char)(ch3) | \
+ ( (long)(unsigned char)(ch2) << 8 ) | \
+ ( (long)(unsigned char)(ch1) << 16 ) | \
+ ( (long)(unsigned char)(ch0) << 24 ) )
+
+#define CBF0_TAG FOURCC_TAG('C', 'B', 'F', '0')
+#define CBFZ_TAG FOURCC_TAG('C', 'B', 'F', 'Z')
+#define CBP0_TAG FOURCC_TAG('C', 'B', 'P', '0')
+#define CBPZ_TAG FOURCC_TAG('C', 'B', 'P', 'Z')
+#define CPL0_TAG FOURCC_TAG('C', 'P', 'L', '0')
+#define CPLZ_TAG FOURCC_TAG('C', 'P', 'L', 'Z')
+#define VPTZ_TAG FOURCC_TAG('V', 'P', 'T', 'Z')
+
+#define VQA_DEBUG 0
+
+#if VQA_DEBUG
+#define vqa_debug printf
+#else
+static inline void vqa_debug(const char *format, ...) { }
+#endif
+
+typedef struct VqaContext {
+
+ AVCodecContext *avctx;
+ DSPContext dsp;
+ AVFrame frame;
+
+ unsigned char *buf;
+ int size;
+
+ unsigned char palette[PALETTE_COUNT * 4];
+
+ int width; /* width of a frame */
+ int height; /* height of a frame */
+ int vector_width; /* width of individual vector */
+ int vector_height; /* height of individual vector */
+ int vqa_version; /* this should be either 1, 2 or 3 */
+
+ unsigned char *codebook; /* the current codebook */
+ int codebook_size;
+ unsigned char *next_codebook_buffer; /* accumulator for next codebook */
+ int next_codebook_buffer_index;
+
+ unsigned char *decode_buffer;
+ int decode_buffer_size;
+
+ /* number of frames to go before replacing codebook */
+ int partial_countdown;
+ int partial_count;
+
+} VqaContext;
+
+static int vqa_decode_init(AVCodecContext *avctx)
+{
+ VqaContext *s = (VqaContext *)avctx->priv_data;
+ unsigned char *vqa_header;
+ int i, j, codebook_index;;
+
+ s->avctx = avctx;
+ avctx->pix_fmt = PIX_FMT_PAL8;
+ avctx->has_b_frames = 0;
+ dsputil_init(&s->dsp, avctx);
+
+ /* make sure the extradata made it */
+ if (s->avctx->extradata_size != VQA_HEADER_SIZE) {
+ printf(" VQA video: expected extradata size of %d\n", VQA_HEADER_SIZE);
+ return -1;
+ }
+
+ /* load up the VQA parameters from the header */
+ vqa_header = (unsigned char *)s->avctx->extradata;
+ s->vqa_version = vqa_header[0];
+ s->width = LE_16(&vqa_header[6]);
+ s->height = LE_16(&vqa_header[8]);
+ s->vector_width = vqa_header[10];
+ s->vector_height = vqa_header[11];
+ s->partial_count = s->partial_countdown = vqa_header[13];
+
+ /* the vector dimensions have to meet very stringent requirements */
+ if ((s->vector_width != 4) ||
+ ((s->vector_height != 2) && (s->vector_height != 4))) {
+ /* return without further initialization */
+ return -1;
+ }
+
+ /* allocate codebooks */
+ s->codebook_size = MAX_CODEBOOK_SIZE;
+ s->codebook = av_malloc(s->codebook_size);
+ s->next_codebook_buffer = av_malloc(s->codebook_size);
+
+ /* initialize the solid-color vectors */
+ if (s->vector_height == 4) {
+ codebook_index = 0xFF00 * 16;
+ for (i = 0; i < 256; i++)
+ for (j = 0; j < 16; j++)
+ s->codebook[codebook_index++] = i;
+ } else {
+ codebook_index = 0xF00 * 8;
+ for (i = 0; i < 256; i++)
+ for (j = 0; j < 8; j++)
+ s->codebook[codebook_index++] = i;
+ }
+ s->next_codebook_buffer_index = 0;
+
+ /* allocate decode buffer */
+ s->decode_buffer_size = (s->width / s->vector_width) *
+ (s->height / s->vector_height) * 2;
+ s->decode_buffer = av_malloc(s->decode_buffer_size);
+
+ s->frame.data[0] = NULL;
+
+ return 0;
+}
+
+#define CHECK_COUNT() \
+ if (dest_index + count > dest_size) { \
+ printf (" VQA video: decode_format80 problem: next op would overflow dest_index\n"); \
+ printf (" VQA video: current dest_index = %d, count = %d, dest_size = %d\n", \
+ dest_index, count, dest_size); \
+ return; \
+ }
+
+static void decode_format80(unsigned char *src, int src_size,
+ unsigned char *dest, int dest_size, int check_size) {
+
+ int src_index = 0;
+ int dest_index = 0;
+ int count;
+ int src_pos;
+ unsigned char color;
+ int i;
+
+ while (src_index < src_size) {
+
+ vqa_debug(" opcode %02X: ", src[src_index]);
+
+ /* 0x80 means that frame is finished */
+ if (src[src_index] == 0x80)
+ return;
+
+ if (dest_index >= dest_size) {
+ printf (" VQA video: decode_format80 problem: dest_index (%d) exceeded dest_size (%d)\n",
+ dest_index, dest_size);
+ return;
+ }
+
+ if (src[src_index] == 0xFF) {
+
+ src_index++;
+ count = LE_16(&src[src_index]);
+ src_index += 2;
+ src_pos = LE_16(&src[src_index]);
+ src_index += 2;
+ vqa_debug("(1) copy %X bytes from absolute pos %X\n", count, src_pos);
+ CHECK_COUNT();
+ for (i = 0; i < count; i++)
+ dest[dest_index + i] = dest[src_pos + i];
+ dest_index += count;
+
+ } else if (src[src_index] == 0xFE) {
+
+ src_index++;
+ count = LE_16(&src[src_index]);
+ src_index += 2;
+ color = src[src_index++];
+ vqa_debug("(2) set %X bytes to %02X\n", count, color);
+ CHECK_COUNT();
+ memset(&dest[dest_index], color, count);
+ dest_index += count;
+
+ } else if ((src[src_index] & 0xC0) == 0xC0) {
+
+ count = (src[src_index++] & 0x3F) + 3;
+ src_pos = LE_16(&src[src_index]);
+ src_index += 2;
+ vqa_debug("(3) copy %X bytes from absolute pos %X\n", count, src_pos);
+ CHECK_COUNT();
+ for (i = 0; i < count; i++)
+ dest[dest_index + i] = dest[src_pos + i];
+ dest_index += count;
+
+ } else if (src[src_index] > 0x80) {
+
+ count = src[src_index++] & 0x3F;
+ vqa_debug("(4) copy %X bytes from source to dest\n", count);
+ CHECK_COUNT();
+ memcpy(&dest[dest_index], &src[src_index], count);
+ src_index += count;
+ dest_index += count;
+
+ } else {
+
+ count = ((src[src_index] & 0x70) >> 4) + 3;
+ src_pos = BE_16(&src[src_index]) & 0x0FFF;
+ src_index += 2;
+ vqa_debug("(5) copy %X bytes from relpos %X\n", count, src_pos);
+ CHECK_COUNT();
+ for (i = 0; i < count; i++)
+ dest[dest_index + i] = dest[dest_index - src_pos + i];
+ dest_index += count;
+ }
+ }
+
+ /* validate that the entire destination buffer was filled; this is
+ * important for decoding frame maps since each vector needs to have a
+ * codebook entry; it is not important for compressed codebooks because
+ * not every entry needs to be filled */
+ if (check_size)
+ if (dest_index < dest_size)
+ printf (" VQA video: decode_format80 problem: decode finished with dest_index (%d) < dest_size (%d)\n",
+ dest_index, dest_size);
+}
+
+static void vqa_decode_chunk(VqaContext *s)
+{
+ unsigned int chunk_type;
+ unsigned int chunk_size;
+ int byte_skip;
+ unsigned int index = 0;
+ int i;
+ unsigned char r, g, b;
+ unsigned int *palette32;
+ int index_shift;
+
+ int cbf0_chunk = -1;
+ int cbfz_chunk = -1;
+ int cbp0_chunk = -1;
+ int cbpz_chunk = -1;
+ int cpl0_chunk = -1;
+ int cplz_chunk = -1;
+ int vptz_chunk = -1;
+
+ int x, y;
+ int lines = 0;
+ int pixel_ptr;
+ int vector_index = 0;
+ int lobyte = 0;
+ int hibyte = 0;
+ int lobytes = 0;
+ int hibytes = s->decode_buffer_size / 2;
+
+ /* first, traverse through the frame and find the subchunks */
+ while (index < s->size) {
+
+ chunk_type = BE_32(&s->buf[index]);
+ chunk_size = BE_32(&s->buf[index + 4]);
+
+ switch (chunk_type) {
+
+ case CBF0_TAG:
+ cbf0_chunk = index;
+ break;
+
+ case CBFZ_TAG:
+ cbfz_chunk = index;
+ break;
+
+ case CBP0_TAG:
+ cbp0_chunk = index;
+ break;
+
+ case CBPZ_TAG:
+ cbpz_chunk = index;
+ break;
+
+ case CPL0_TAG:
+ cpl0_chunk = index;
+ break;
+
+ case CPLZ_TAG:
+ cplz_chunk = index;
+ break;
+
+ case VPTZ_TAG:
+ vptz_chunk = index;
+ break;
+
+ default:
+ printf (" VQA video: Found unknown chunk type: %c%c%c%c (%08X)\n",
+ (chunk_type >> 24) & 0xFF,
+ (chunk_type >> 16) & 0xFF,
+ (chunk_type >> 8) & 0xFF,
+ (chunk_type >> 0) & 0xFF,
+ chunk_type);
+ break;
+ }
+
+ byte_skip = chunk_size & 0x01;
+ index += (CHUNK_PREAMBLE_SIZE + chunk_size + byte_skip);
+ }
+
+ /* next, deal with the palette */
+ if ((cpl0_chunk != -1) && (cplz_chunk != -1)) {
+
+ /* a chunk should not have both chunk types */
+ printf (" VQA video: problem: found both CPL0 and CPLZ chunks\n");
+ return;
+ }
+
+ /* decompress the palette chunk */
+ if (cplz_chunk != -1) {
+
+/* yet to be handled */
+
+ }
+
+ /* convert the RGB palette into the machine's endian format */
+ if (cpl0_chunk != -1) {
+
+ chunk_size = BE_32(&s->buf[cpl0_chunk + 4]);
+ /* sanity check the palette size */
+ if (chunk_size / 3 > 256) {
+ printf (" VQA video: problem: found a palette chunk with %d colors\n",
+ chunk_size / 3);
+ return;
+ }
+ cpl0_chunk += CHUNK_PREAMBLE_SIZE;
+ palette32 = (unsigned int *)s->palette;
+ for (i = 0; i < chunk_size / 3; i++) {
+ /* scale by 4 to transform 6-bit palette -> 8-bit */
+ r = s->buf[cpl0_chunk++] * 4;
+ g = s->buf[cpl0_chunk++] * 4;
+ b = s->buf[cpl0_chunk++] * 4;
+ palette32[i] = (r << 16) | (g << 8) | (b);
+ }
+ }
+
+ /* next, look for a full codebook */
+ if ((cbf0_chunk != -1) && (cbfz_chunk != -1)) {
+
+ /* a chunk should not have both chunk types */
+ printf (" VQA video: problem: found both CBF0 and CBFZ chunks\n");
+ return;
+ }
+
+ /* decompress the full codebook chunk */
+ if (cbfz_chunk != -1) {
+
+ chunk_size = BE_32(&s->buf[cbfz_chunk + 4]);
+ cbfz_chunk += CHUNK_PREAMBLE_SIZE;
+ decode_format80(&s->buf[cbfz_chunk], chunk_size,
+ s->codebook, s->codebook_size, 0);
+ }
+
+ /* copy a full codebook */
+ if (cbf0_chunk != -1) {
+
+ chunk_size = BE_32(&s->buf[cbf0_chunk + 4]);
+ /* sanity check the full codebook size */
+ if (chunk_size > MAX_CODEBOOK_SIZE) {
+ printf (" VQA video: problem: CBF0 chunk too large (0x%X bytes)\n",
+ chunk_size);
+ return;
+ }
+ cbf0_chunk += CHUNK_PREAMBLE_SIZE;
+
+ memcpy(s->codebook, &s->buf[cbf0_chunk], chunk_size);
+ }
+
+ /* decode the frame */
+ if (vptz_chunk == -1) {
+
+ /* something is wrong if there is no VPTZ chunk */
+ printf (" VQA video: problem: no VPTZ chunk found\n");
+ return;
+ }
+
+ chunk_size = BE_32(&s->buf[vptz_chunk + 4]);
+ vptz_chunk += CHUNK_PREAMBLE_SIZE;
+ decode_format80(&s->buf[vptz_chunk], chunk_size,
+ s->decode_buffer, s->decode_buffer_size, 1);
+
+ /* render the final PAL8 frame */
+ if (s->vector_height == 4)
+ index_shift = 4;
+ else
+ index_shift = 3;
+ for (y = 0; y < s->frame.linesize[0] * s->height;
+ y += s->frame.linesize[0] * s->vector_height) {
+
+ for (x = y; x < y + s->width; x += 4, lobytes++, hibytes++) {
+ pixel_ptr = x;
+
+ /* get the vector index, the method for which varies according to
+ * VQA file version */
+ switch (s->vqa_version) {
+
+ case 1:
+/* still need sample media for this case (only one game, "Legend of
+ * Kyrandia III : Malcolm's Revenge", is known to use this version) */
+ lines = 0;
+ break;
+
+ case 2:
+ lobyte = s->decode_buffer[lobytes];
+ hibyte = s->decode_buffer[hibytes];
+ vector_index = (hibyte << 8) | lobyte;
+ vector_index <<= index_shift;
+ lines = s->vector_height;
+ break;
+
+ case 3:
+/* not implemented yet */
+ lines = 0;
+ break;
+ }
+
+ while (lines--) {
+ s->frame.data[0][pixel_ptr + 0] = s->codebook[vector_index++];
+ s->frame.data[0][pixel_ptr + 1] = s->codebook[vector_index++];
+ s->frame.data[0][pixel_ptr + 2] = s->codebook[vector_index++];
+ s->frame.data[0][pixel_ptr + 3] = s->codebook[vector_index++];
+ pixel_ptr += s->frame.linesize[0];
+ }
+ }
+ }
+
+ /* handle partial codebook */
+ if ((cbp0_chunk != -1) && (cbpz_chunk != -1)) {
+ /* a chunk should not have both chunk types */
+ printf (" VQA video: problem: found both CBP0 and CBPZ chunks\n");
+ return;
+ }
+
+ if (cbp0_chunk != -1) {
+
+ chunk_size = BE_32(&s->buf[cbp0_chunk + 4]);
+ cbp0_chunk += CHUNK_PREAMBLE_SIZE;
+
+ /* accumulate partial codebook */
+ memcpy(&s->next_codebook_buffer[s->next_codebook_buffer_index],
+ &s->buf[cbp0_chunk], chunk_size);
+ s->next_codebook_buffer_index += chunk_size;
+
+ s->partial_countdown--;
+ if (s->partial_countdown == 0) {
+
+ /* time to replace codebook */
+ memcpy(s->codebook, s->next_codebook_buffer,
+ s->next_codebook_buffer_index);
+
+ /* reset accounting */
+ s->next_codebook_buffer_index = 0;
+ s->partial_countdown = s->partial_count;
+ }
+ }
+
+ if (cbpz_chunk != -1) {
+
+ chunk_size = BE_32(&s->buf[cbpz_chunk + 4]);
+ cbpz_chunk += CHUNK_PREAMBLE_SIZE;
+
+ /* accumulate partial codebook */
+ memcpy(&s->next_codebook_buffer[s->next_codebook_buffer_index],
+ &s->buf[cbpz_chunk], chunk_size);
+ s->next_codebook_buffer_index += chunk_size;
+
+ s->partial_countdown--;
+ if (s->partial_countdown == 0) {
+
+ /* decompress codebook */
+ decode_format80(s->next_codebook_buffer,
+ s->next_codebook_buffer_index,
+ s->codebook, s->codebook_size, 0);
+
+ /* reset accounting */
+ s->next_codebook_buffer_index = 0;
+ s->partial_countdown = s->partial_count;
+ }
+ }
+}
+
+static int vqa_decode_frame(AVCodecContext *avctx,
+ void *data, int *data_size,
+ uint8_t *buf, int buf_size)
+{
+ VqaContext *s = (VqaContext *)avctx->priv_data;
+
+ s->buf = buf;
+ s->size = buf_size;
+
+ if (s->frame.data[0])
+ avctx->release_buffer(avctx, &s->frame);
+
+ if (avctx->get_buffer(avctx, &s->frame)) {
+ printf (" VQA Video: get_buffer() failed\n");
+ return -1;
+ }
+
+ vqa_decode_chunk(s);
+
+ /* make the palette available on the way out */
+ memcpy(s->frame.data[1], s->palette, PALETTE_COUNT * 4);
+
+ *data_size = sizeof(AVFrame);
+ *(AVFrame*)data = s->frame;
+
+ /* report that the buffer was completely consumed */
+ return buf_size;
+}
+
+static int vqa_decode_end(AVCodecContext *avctx)
+{
+ VqaContext *s = (VqaContext *)avctx->priv_data;
+
+ av_free(s->codebook);
+ av_free(s->next_codebook_buffer);
+ av_free(s->decode_buffer);
+
+ if (s->frame.data[0])
+ avctx->release_buffer(avctx, &s->frame);
+
+ return 0;
+}
+
+AVCodec vqa_decoder = {
+ "vqavideo",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_WS_VQA,
+ sizeof(VqaContext),
+ vqa_decode_init,
+ NULL,
+ vqa_decode_end,
+ vqa_decode_frame,
+ CODEC_CAP_DR1,
+};
diff --git a/src/libffmpeg/libavcodec/wmadec.c b/src/libffmpeg/libavcodec/wmadec.c
index 8d3763213..15b15f23f 100644
--- a/src/libffmpeg/libavcodec/wmadec.c
+++ b/src/libffmpeg/libavcodec/wmadec.c
@@ -25,9 +25,6 @@
#include "avcodec.h"
#include "dsputil.h"
-//#define DEBUG_PARAMS
-//#define DEBUG_TRACE
-
/* size of blocks */
#define BLOCK_MIN_BITS 7
#define BLOCK_MAX_BITS 11
@@ -114,6 +111,10 @@ typedef struct WMADecodeContext {
float lsp_pow_e_table[256];
float lsp_pow_m_table1[(1 << LSP_POW_BITS)];
float lsp_pow_m_table2[(1 << LSP_POW_BITS)];
+
+#ifdef TRACE
+ int frame_count;
+#endif
} WMADecodeContext;
typedef struct CoefVLCTable {
@@ -127,57 +128,18 @@ static void wma_lsp_to_curve_init(WMADecodeContext *s, int frame_len);
#include "wmadata.h"
-#ifdef DEBUG_TRACE
-#include <stdarg.h>
-int frame_count;
-
-static FILE *flog;
-
-void trace(const char *fmt, ...)
-{
- va_list ap;
-
-
- if (!flog) {
- flog = fopen("/tmp/out.log", "w");
- setlinebuf(flog);
- }
-
- va_start(ap, fmt);
- vfprintf(flog, fmt, ap);
- va_end(ap);
-}
-
-#define get_bits(s, n) get_bits_trace(s, n)
-#define get_vlc(s, vlc) get_vlc_trace(s, vlc)
-
-unsigned int get_bits_trace(GetBitContext *s, int n)
-{
- unsigned int val;
- val = (get_bits)(s, n);
- trace("get_bits(%d) : 0x%x\n", n, val);
- return val;
-}
-
-static int get_vlc_trace(GetBitContext *s, VLC *vlc)
-{
- int code;
- code = (get_vlc)(s, vlc);
- trace("get_vlc() : %d\n", code);
- return code;
-}
-
+#ifdef TRACE
static void dump_shorts(const char *name, const short *tab, int n)
{
int i;
- trace("%s[%d]:\n", name, n);
+ tprintf("%s[%d]:\n", name, n);
for(i=0;i<n;i++) {
if ((i & 7) == 0)
- trace("%4d: ", i);
- trace(" %5d.0", tab[i]);
+ tprintf("%4d: ", i);
+ tprintf(" %5d.0", tab[i]);
if ((i & 7) == 7)
- trace("\n");
+ tprintf("\n");
}
}
@@ -185,22 +147,17 @@ static void dump_floats(const char *name, int prec, const float *tab, int n)
{
int i;
- trace("%s[%d]:\n", name, n);
+ tprintf("%s[%d]:\n", name, n);
for(i=0;i<n;i++) {
if ((i & 7) == 0)
- trace("%4d: ", i);
- trace(" %8.*f", prec, tab[i]);
+ tprintf("%4d: ", i);
+ tprintf(" %8.*f", prec, tab[i]);
if ((i & 7) == 7)
- trace("\n");
+ tprintf("\n");
}
if ((i & 7) != 0)
- trace("\n");
+ tprintf("\n");
}
-
-#else
-
-#define trace(fmt, args...)
-
#endif
/* XXX: use same run/length optimization as mpeg decoders */
@@ -359,16 +316,14 @@ static int wma_decode_init(AVCodecContext * avctx)
high_freq = high_freq * 0.5;
}
}
-#ifdef DEBUG_PARAMS
- printf("flags1=0x%x flags2=0x%x\n", flags1, flags2);
- printf("version=%d channels=%d sample_rate=%d bitrate=%d block_align=%d\n",
+ dprintf("flags1=0x%x flags2=0x%x\n", flags1, flags2);
+ dprintf("version=%d channels=%d sample_rate=%d bitrate=%d block_align=%d\n",
s->version, s->nb_channels, s->sample_rate, s->bit_rate,
s->block_align);
- printf("bps=%f bps1=%f high_freq=%f bitoffset=%d\n",
+ dprintf("bps=%f bps1=%f high_freq=%f bitoffset=%d\n",
bps, bps1, high_freq, s->byte_offset_bits);
- printf("use_noise_coding=%d use_exp_vlc=%d nb_block_sizes=%d\n",
+ dprintf("use_noise_coding=%d use_exp_vlc=%d nb_block_sizes=%d\n",
s->use_noise_coding, s->use_exp_vlc, s->nb_block_sizes);
-#endif
/* compute the scale factor band sizes for each MDCT block size */
{
@@ -458,28 +413,28 @@ static int wma_decode_init(AVCodecContext * avctx)
}
s->exponent_high_sizes[k] = j;
#if 0
- trace("%5d: coefs_end=%d high_band_start=%d nb_high_bands=%d: ",
+ tprintf("%5d: coefs_end=%d high_band_start=%d nb_high_bands=%d: ",
s->frame_len >> k,
s->coefs_end[k],
s->high_band_start[k],
s->exponent_high_sizes[k]);
for(j=0;j<s->exponent_high_sizes[k];j++)
- trace(" %d", s->exponent_high_bands[k][j]);
- trace("\n");
+ tprintf(" %d", s->exponent_high_bands[k][j]);
+ tprintf("\n");
#endif
}
}
-#ifdef DEBUG_TRACE
+#ifdef TRACE
{
int i, j;
for(i = 0; i < s->nb_block_sizes; i++) {
- trace("%5d: n=%2d:",
+ tprintf("%5d: n=%2d:",
s->frame_len >> i,
s->exponent_sizes[i]);
for(j=0;j<s->exponent_sizes[i];j++)
- trace(" %d", s->exponent_bands[i][j]);
- trace("\n");
+ tprintf(" %d", s->exponent_bands[i][j]);
+ tprintf("\n");
}
}
#endif
@@ -511,7 +466,7 @@ static int wma_decode_init(AVCodecContext * avctx)
else
s->noise_mult = 0.04;
-#if defined(DEBUG_TRACE)
+#ifdef TRACE
for(i=0;i<NOISE_TAB_SIZE;i++)
s->noise_table[i] = 1.0 * s->noise_mult;
#else
@@ -741,7 +696,9 @@ static int wma_decode_block(WMADecodeContext *s)
int nb_coefs[MAX_CHANNELS];
float mdct_norm;
- trace("***decode_block: %d:%d\n", frame_count - 1, s->block_num);
+#ifdef TRACE
+ tprintf("***decode_block: %d:%d\n", s->frame_count - 1, s->block_num);
+#endif
/* compute current block length */
if (s->use_variable_block_len) {
@@ -987,7 +944,7 @@ static int wma_decode_block(WMADecodeContext *s)
}
exp_power[j] = e2 / n;
last_high_band = j;
- trace("%d: power=%f (%d)\n", j, exp_power[j], n);
+ tprintf("%d: power=%f (%d)\n", j, exp_power[j], n);
}
exp_ptr += n;
}
@@ -1045,7 +1002,7 @@ static int wma_decode_block(WMADecodeContext *s)
}
}
-#ifdef DEBUG_TRACE
+#ifdef TRACE
for(ch = 0; ch < s->nb_channels; ch++) {
if (s->channel_coded[ch]) {
dump_floats("exponents", 3, s->exponents[ch], s->block_len);
@@ -1062,9 +1019,7 @@ static int wma_decode_block(WMADecodeContext *s)
/* no need to optimize this case because it should almost
never happen */
if (!s->channel_coded[0]) {
-#ifdef DEBUG_TRACE
- trace("rare ms-stereo case happened\n");
-#endif
+ tprintf("rare ms-stereo case happened\n");
memset(s->coefs[0], 0, sizeof(float) * s->block_len);
s->channel_coded[0] = 1;
}
@@ -1176,7 +1131,9 @@ static int wma_decode_frame(WMADecodeContext *s, int16_t *samples)
int16_t *ptr;
float *iptr;
- trace("***decode_frame: %d size=%d\n", frame_count++, s->frame_len);
+#ifdef TRACE
+ tprintf("***decode_frame: %d size=%d\n", s->frame_count++, s->frame_len);
+#endif
/* read each block */
s->block_num = 0;
@@ -1213,7 +1170,7 @@ static int wma_decode_frame(WMADecodeContext *s, int16_t *samples)
s->frame_len * sizeof(float));
}
-#ifdef DEBUG_TRACE
+#ifdef TRACE
dump_shorts("samples", samples, n * s->nb_channels);
#endif
return 0;
@@ -1228,7 +1185,7 @@ static int wma_decode_superframe(AVCodecContext *avctx,
uint8_t *q;
int16_t *samples;
- trace("***decode_superframe:\n");
+ tprintf("***decode_superframe:\n");
samples = data;
diff --git a/src/libffmpeg/libavcodec/wmv2.c b/src/libffmpeg/libavcodec/wmv2.c
index ea4f407eb..f68664820 100644
--- a/src/libffmpeg/libavcodec/wmv2.c
+++ b/src/libffmpeg/libavcodec/wmv2.c
@@ -64,7 +64,7 @@ static int encode_ext_header(Wmv2Context *w){
PutBitContext pb;
int code;
- init_put_bits(&pb, s->avctx->extradata, s->avctx->extradata_size, NULL, NULL);
+ init_put_bits(&pb, s->avctx->extradata, s->avctx->extradata_size);
put_bits(&pb, 5, s->avctx->frame_rate / s->avctx->frame_rate_base); //yes 29.97 -> 29
put_bits(&pb, 11, FFMIN(s->bit_rate/1024, 2047));
@@ -101,7 +101,6 @@ static int wmv2_encode_init(AVCodecContext *avctx){
}
static int wmv2_encode_end(AVCodecContext *avctx){
- Wmv2Context * const w= avctx->priv_data;
if(MPV_encode_end(avctx) < 0)
return -1;
@@ -587,7 +586,6 @@ static inline int wmv2_decode_inter_block(Wmv2Context *w, DCTELEM *block, int n,
static void wmv2_add_block(Wmv2Context *w, DCTELEM *block1, uint8_t *dst, int stride, int n){
MpegEncContext * const s= &w->s;
- uint8_t temp[2][64];
switch(w->abt_type_table[n]){
case 0:
diff --git a/src/libffmpeg/libavcodec/xan.c b/src/libffmpeg/libavcodec/xan.c
new file mode 100644
index 000000000..8359782e6
--- /dev/null
+++ b/src/libffmpeg/libavcodec/xan.c
@@ -0,0 +1,820 @@
+/*
+ * Wing Commander/Xan Video Decoder
+ * 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
+ *
+ */
+
+/**
+ * @file xan.c
+ * Xan video decoder for Wing Commander III & IV computer games
+ * by Mario Brito (mbrito@student.dei.uc.pt)
+ * and Mike Melanson (melanson@pcisys.net)
+ *
+ * The xan_wc3 decoder outputs the following colorspaces natively:
+ * PAL8 (default), RGB555, RGB565, RGB24, BGR24, RGBA32, YUV444P
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "common.h"
+#include "avcodec.h"
+#include "dsputil.h"
+
+#define PALETTE_COUNT 256
+#define PALETTE_CONTROL_SIZE ((256 * 3) + 1)
+
+typedef struct XanContext {
+
+ AVCodecContext *avctx;
+ DSPContext dsp;
+ AVFrame last_frame;
+ AVFrame current_frame;
+
+ unsigned char *buf;
+ int size;
+
+ unsigned char palette[PALETTE_COUNT * 4];
+
+ /* scratch space */
+ unsigned char *buffer1;
+ unsigned char *buffer2;
+
+} XanContext;
+
+#define BE_16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1])
+#define LE_16(x) ((((uint8_t*)(x))[1] << 8) | ((uint8_t*)(x))[0])
+#define LE_32(x) ((((uint8_t*)(x))[3] << 24) | \
+ (((uint8_t*)(x))[2] << 16) | \
+ (((uint8_t*)(x))[1] << 8) | \
+ ((uint8_t*)(x))[0])
+
+/* RGB -> YUV conversion stuff */
+#define SCALEFACTOR 65536
+#define CENTERSAMPLE 128
+
+#define COMPUTE_Y(r, g, b) \
+ (unsigned char) \
+ ((y_r_table[r] + y_g_table[g] + y_b_table[b]) / SCALEFACTOR)
+#define COMPUTE_U(r, g, b) \
+ (unsigned char) \
+ ((u_r_table[r] + u_g_table[g] + u_b_table[b]) / SCALEFACTOR + CENTERSAMPLE)
+#define COMPUTE_V(r, g, b) \
+ (unsigned char) \
+ ((v_r_table[r] + v_g_table[g] + v_b_table[b]) / SCALEFACTOR + CENTERSAMPLE)
+
+#define Y_R (SCALEFACTOR * 0.29900)
+#define Y_G (SCALEFACTOR * 0.58700)
+#define Y_B (SCALEFACTOR * 0.11400)
+
+#define U_R (SCALEFACTOR * -0.16874)
+#define U_G (SCALEFACTOR * -0.33126)
+#define U_B (SCALEFACTOR * 0.50000)
+
+#define V_R (SCALEFACTOR * 0.50000)
+#define V_G (SCALEFACTOR * -0.41869)
+#define V_B (SCALEFACTOR * -0.08131)
+
+/*
+ * Precalculate all of the YUV tables since it requires fewer than
+ * 10 kilobytes to store them.
+ */
+static int y_r_table[256];
+static int y_g_table[256];
+static int y_b_table[256];
+
+static int u_r_table[256];
+static int u_g_table[256];
+static int u_b_table[256];
+
+static int v_r_table[256];
+static int v_g_table[256];
+static int v_b_table[256];
+
+static int xan_decode_init(AVCodecContext *avctx)
+{
+ XanContext *s = avctx->priv_data;
+ int i;
+
+ s->avctx = avctx;
+
+ if ((avctx->codec->id == CODEC_ID_XAN_WC3) &&
+ (s->avctx->extradata_size != sizeof(AVPaletteControl))) {
+ printf (" WC3 Xan video: expected extradata_size of %d\n",
+ sizeof(AVPaletteControl));
+ return -1;
+ }
+
+ avctx->pix_fmt = PIX_FMT_PAL8;
+ avctx->has_b_frames = 0;
+ dsputil_init(&s->dsp, avctx);
+
+ /* initialize the RGB -> YUV tables */
+ for (i = 0; i < 256; i++) {
+ y_r_table[i] = Y_R * i;
+ y_g_table[i] = Y_G * i;
+ y_b_table[i] = Y_B * i;
+
+ u_r_table[i] = U_R * i;
+ u_g_table[i] = U_G * i;
+ u_b_table[i] = U_B * i;
+
+ v_r_table[i] = V_R * i;
+ v_g_table[i] = V_G * i;
+ v_b_table[i] = V_B * i;
+ }
+
+ s->buffer1 = av_malloc(avctx->width * avctx->height);
+ s->buffer2 = av_malloc(avctx->width * avctx->height);
+ if (!s->buffer1 || !s->buffer2)
+ return -1;
+
+ return 0;
+}
+
+/* This function is used in lieu of memcpy(). This decoder can not use
+ * memcpy because the memory locations often overlap and
+ * memcpy doesn't like that; it's not uncommon, for example, for
+ * dest = src+1, to turn byte A into pattern AAAAAAAA.
+ * This was originally repz movsb in Intel x86 ASM. */
+static inline void bytecopy(unsigned char *dest, unsigned char *src, int count)
+{
+ int i;
+
+ for (i = 0; i < count; i++)
+ dest[i] = src[i];
+}
+
+static int xan_huffman_decode(unsigned char *dest, unsigned char *src)
+{
+ unsigned char byte = *src++;
+ unsigned char ival = byte + 0x16;
+ unsigned char * ptr = src + byte*2;
+ unsigned char val = ival;
+ int counter = 0;
+
+ unsigned char bits = *ptr++;
+
+ while ( val != 0x16 ) {
+ if ( (1 << counter) & bits )
+ val = src[byte + val - 0x17];
+ else
+ val = src[val - 0x17];
+
+ if ( val < 0x16 ) {
+ *dest++ = val;
+ val = ival;
+ }
+
+ if (counter++ == 7) {
+ counter = 0;
+ bits = *ptr++;
+ }
+ }
+
+ return 0;
+}
+
+static void xan_unpack(unsigned char *dest, unsigned char *src)
+{
+ unsigned char opcode;
+ int size;
+ int offset;
+ int byte1, byte2, byte3;
+
+ for (;;) {
+ opcode = *src++;
+
+ if ( (opcode & 0x80) == 0 ) {
+
+ offset = *src++;
+
+ size = opcode & 3;
+ bytecopy(dest, src, size); dest += size; src += size;
+
+ size = ((opcode & 0x1c) >> 2) + 3;
+ bytecopy (dest, dest - (((opcode & 0x60) << 3) + offset + 1), size);
+ dest += size;
+
+ } else if ( (opcode & 0x40) == 0 ) {
+
+ byte1 = *src++;
+ byte2 = *src++;
+
+ size = byte1 >> 6;
+ bytecopy (dest, src, size); dest += size; src += size;
+
+ size = (opcode & 0x3f) + 4;
+ bytecopy (dest, dest - (((byte1 & 0x3f) << 8) + byte2 + 1), size);
+ dest += size;
+
+ } else if ( (opcode & 0x20) == 0 ) {
+
+ byte1 = *src++;
+ byte2 = *src++;
+ byte3 = *src++;
+
+ size = opcode & 3;
+ bytecopy (dest, src, size); dest += size; src += size;
+
+ size = byte3 + 5 + ((opcode & 0xc) << 6);
+ bytecopy (dest,
+ dest - ((((opcode & 0x10) >> 4) << 0x10) + 1 + (byte1 << 8) + byte2),
+ size);
+ dest += size;
+ } else {
+ size = ((opcode & 0x1f) << 2) + 4;
+
+ if (size > 0x70)
+ break;
+
+ bytecopy (dest, src, size); dest += size; src += size;
+ }
+ }
+
+ size = opcode & 3;
+ bytecopy(dest, src, size); dest += size; src += size;
+}
+
+static void inline xan_wc3_build_palette(XanContext *s,
+ unsigned char *palette_data)
+{
+ int i;
+ unsigned char r, g, b;
+ unsigned short *palette16;
+ unsigned int *palette32;
+
+ /* transform the palette passed through the palette control structure
+ * into the necessary internal format depending on colorspace */
+
+ switch (s->avctx->pix_fmt) {
+
+ case PIX_FMT_RGB555:
+ palette16 = (unsigned short *)s->palette;
+ for (i = 0; i < PALETTE_COUNT; i++) {
+ r = *palette_data++;
+ g = *palette_data++;
+ b = *palette_data++;
+ palette16[i] =
+ ((r >> 3) << 10) |
+ ((g >> 3) << 5) |
+ ((b >> 3) << 0);
+ }
+ break;
+
+ case PIX_FMT_RGB565:
+ palette16 = (unsigned short *)s->palette;
+ for (i = 0; i < PALETTE_COUNT; i++) {
+ r = *palette_data++;
+ g = *palette_data++;
+ b = *palette_data++;
+ palette16[i] =
+ ((r >> 3) << 11) |
+ ((g >> 2) << 5) |
+ ((b >> 3) << 0);
+ }
+ break;
+
+ case PIX_FMT_RGB24:
+ for (i = 0; i < PALETTE_COUNT; i++) {
+ s->palette[i * 4 + 0] = *palette_data++;
+ s->palette[i * 4 + 1] = *palette_data++;
+ s->palette[i * 4 + 2] = *palette_data++;
+ }
+ break;
+
+ case PIX_FMT_BGR24:
+ for (i = 0; i < PALETTE_COUNT; i++) {
+ r = *palette_data++;
+ g = *palette_data++;
+ b = *palette_data++;
+ s->palette[i * 4 + 0] = b;
+ s->palette[i * 4 + 1] = g;
+ s->palette[i * 4 + 2] = r;
+ }
+ break;
+
+ case PIX_FMT_PAL8:
+ case PIX_FMT_RGBA32:
+ palette32 = (unsigned int *)s->palette;
+ for (i = 0; i < PALETTE_COUNT; i++) {
+ r = *palette_data++;
+ g = *palette_data++;
+ b = *palette_data++;
+ palette32[i] = (r << 16) | (g << 8) | (b);
+ }
+ break;
+
+ case PIX_FMT_YUV444P:
+ for (i = 0; i < PALETTE_COUNT; i++) {
+ r = *palette_data++;
+ g = *palette_data++;
+ b = *palette_data++;
+ s->palette[i * 4 + 0] = COMPUTE_Y(r, g, b);
+ s->palette[i * 4 + 1] = COMPUTE_U(r, g, b);
+ s->palette[i * 4 + 2] = COMPUTE_V(r, g, b);
+ }
+ break;
+
+ default:
+ printf (" Xan WC3: Unhandled colorspace\n");
+ break;
+ }
+}
+
+/* advance current_x variable; reset accounting variables if current_x
+ * moves beyond width */
+#define ADVANCE_CURRENT_X() \
+ current_x++; \
+ if (current_x >= width) { \
+ index += line_inc; \
+ current_x = 0; \
+ }
+
+static void inline xan_wc3_output_pixel_run(XanContext *s,
+ unsigned char *pixel_buffer, int x, int y, int pixel_count)
+{
+ int stride;
+ int line_inc;
+ int index;
+ int current_x;
+ int width = s->avctx->width;
+ unsigned char pix;
+ unsigned char *palette_plane;
+ unsigned char *y_plane;
+ unsigned char *u_plane;
+ unsigned char *v_plane;
+ unsigned char *rgb_plane;
+ unsigned short *rgb16_plane;
+ unsigned short *palette16;
+ unsigned int *rgb32_plane;
+ unsigned int *palette32;
+
+ switch (s->avctx->pix_fmt) {
+
+ case PIX_FMT_PAL8:
+ palette_plane = s->current_frame.data[0];
+ stride = s->current_frame.linesize[0];
+ line_inc = stride - width;
+ index = y * stride + x;
+ current_x = x;
+ while(pixel_count--) {
+
+ /* don't do a memcpy() here; keyframes generally copy an entire
+ * frame of data and the stride needs to be accounted for */
+ palette_plane[index++] = *pixel_buffer++;
+
+ ADVANCE_CURRENT_X();
+ }
+ break;
+
+ case PIX_FMT_RGB555:
+ case PIX_FMT_RGB565:
+ rgb16_plane = (unsigned short *)s->current_frame.data[0];
+ palette16 = (unsigned short *)s->palette;
+ stride = s->current_frame.linesize[0] / 2;
+ line_inc = stride - width;
+ index = y * stride + x;
+ current_x = x;
+ while(pixel_count--) {
+
+ rgb16_plane[index++] = palette16[*pixel_buffer++];
+
+ ADVANCE_CURRENT_X();
+ }
+ break;
+
+ case PIX_FMT_RGB24:
+ case PIX_FMT_BGR24:
+ rgb_plane = s->current_frame.data[0];
+ stride = s->current_frame.linesize[0];
+ line_inc = stride - width * 3;
+ index = y * stride + x * 3;
+ current_x = x;
+ while(pixel_count--) {
+ pix = *pixel_buffer++;
+
+ rgb_plane[index++] = s->palette[pix * 4 + 0];
+ rgb_plane[index++] = s->palette[pix * 4 + 1];
+ rgb_plane[index++] = s->palette[pix * 4 + 2];
+
+ ADVANCE_CURRENT_X();
+ }
+ break;
+
+ case PIX_FMT_RGBA32:
+ rgb32_plane = (unsigned int *)s->current_frame.data[0];
+ palette32 = (unsigned int *)s->palette;
+ stride = s->current_frame.linesize[0] / 4;
+ line_inc = stride - width;
+ index = y * stride + x;
+ current_x = x;
+ while(pixel_count--) {
+
+ rgb32_plane[index++] = palette32[*pixel_buffer++];
+
+ ADVANCE_CURRENT_X();
+ }
+ break;
+
+ case PIX_FMT_YUV444P:
+ y_plane = s->current_frame.data[0];
+ u_plane = s->current_frame.data[1];
+ v_plane = s->current_frame.data[2];
+ stride = s->current_frame.linesize[0];
+ line_inc = stride - width;
+ index = y * stride + x;
+ current_x = x;
+ while(pixel_count--) {
+ pix = *pixel_buffer++;
+
+ y_plane[index] = s->palette[pix * 4 + 0];
+ u_plane[index] = s->palette[pix * 4 + 1];
+ v_plane[index] = s->palette[pix * 4 + 2];
+
+ index++;
+ ADVANCE_CURRENT_X();
+ }
+ break;
+
+ default:
+ printf (" Xan WC3: Unhandled colorspace\n");
+ break;
+ }
+}
+
+#define ADVANCE_CURFRAME_X() \
+ curframe_x++; \
+ if (curframe_x >= width) { \
+ curframe_index += line_inc; \
+ curframe_x = 0; \
+ }
+
+#define ADVANCE_PREVFRAME_X() \
+ prevframe_x++; \
+ if (prevframe_x >= width) { \
+ prevframe_index += line_inc; \
+ prevframe_x = 0; \
+ }
+
+static void inline xan_wc3_copy_pixel_run(XanContext *s,
+ int x, int y, int pixel_count, int motion_x, int motion_y)
+{
+ int stride;
+ int line_inc;
+ int curframe_index, prevframe_index;
+ int curframe_x, prevframe_x;
+ int width = s->avctx->width;
+ unsigned char *palette_plane, *prev_palette_plane;
+ unsigned char *y_plane, *u_plane, *v_plane;
+ unsigned char *prev_y_plane, *prev_u_plane, *prev_v_plane;
+ unsigned char *rgb_plane, *prev_rgb_plane;
+ unsigned short *rgb16_plane, *prev_rgb16_plane;
+ unsigned int *rgb32_plane, *prev_rgb32_plane;
+
+ switch (s->avctx->pix_fmt) {
+
+ case PIX_FMT_PAL8:
+ palette_plane = s->current_frame.data[0];
+ prev_palette_plane = s->last_frame.data[0];
+ stride = s->current_frame.linesize[0];
+ line_inc = stride - width;
+ curframe_index = y * stride + x;
+ curframe_x = x;
+ prevframe_index = (y + motion_y) * stride + x + motion_x;
+ prevframe_x = x + motion_x;
+ while(pixel_count--) {
+
+ palette_plane[curframe_index++] =
+ prev_palette_plane[prevframe_index++];
+
+ ADVANCE_CURFRAME_X();
+ ADVANCE_PREVFRAME_X();
+ }
+ break;
+
+ case PIX_FMT_RGB555:
+ case PIX_FMT_RGB565:
+ rgb16_plane = (unsigned short *)s->current_frame.data[0];
+ prev_rgb16_plane = (unsigned short *)s->last_frame.data[0];
+ stride = s->current_frame.linesize[0] / 2;
+ line_inc = stride - width;
+ curframe_index = y * stride + x;
+ curframe_x = x;
+ prevframe_index = (y + motion_y) * stride + x + motion_x;
+ prevframe_x = x + motion_x;
+ while(pixel_count--) {
+
+ rgb16_plane[curframe_index++] =
+ prev_rgb16_plane[prevframe_index++];
+
+ ADVANCE_CURFRAME_X();
+ ADVANCE_PREVFRAME_X();
+ }
+ break;
+
+ case PIX_FMT_RGB24:
+ case PIX_FMT_BGR24:
+ rgb_plane = s->current_frame.data[0];
+ prev_rgb_plane = s->last_frame.data[0];
+ stride = s->current_frame.linesize[0];
+ line_inc = stride - width * 3;
+ curframe_index = y * stride + x * 3;
+ curframe_x = x;
+ prevframe_index = (y + motion_y) * stride +
+ (3 * (x + motion_x));
+ prevframe_x = x + motion_x;
+ while(pixel_count--) {
+
+ rgb_plane[curframe_index++] = prev_rgb_plane[prevframe_index++];
+ rgb_plane[curframe_index++] = prev_rgb_plane[prevframe_index++];
+ rgb_plane[curframe_index++] = prev_rgb_plane[prevframe_index++];
+
+ ADVANCE_CURFRAME_X();
+ ADVANCE_PREVFRAME_X();
+ }
+ break;
+
+ case PIX_FMT_RGBA32:
+ rgb32_plane = (unsigned int *)s->current_frame.data[0];
+ prev_rgb32_plane = (unsigned int *)s->last_frame.data[0];
+ stride = s->current_frame.linesize[0] / 4;
+ line_inc = stride - width;
+ curframe_index = y * stride + x;
+ curframe_x = x;
+ prevframe_index = (y + motion_y) * stride + x + motion_x;
+ prevframe_x = x + motion_x;
+ while(pixel_count--) {
+
+ rgb32_plane[curframe_index++] =
+ prev_rgb32_plane[prevframe_index++];
+
+ ADVANCE_CURFRAME_X();
+ ADVANCE_PREVFRAME_X();
+ }
+ break;
+
+ case PIX_FMT_YUV444P:
+ y_plane = s->current_frame.data[0];
+ u_plane = s->current_frame.data[1];
+ v_plane = s->current_frame.data[2];
+ prev_y_plane = s->last_frame.data[0];
+ prev_u_plane = s->last_frame.data[1];
+ prev_v_plane = s->last_frame.data[2];
+ stride = s->current_frame.linesize[0];
+ line_inc = stride - width;
+ curframe_index = y * stride + x;
+ curframe_x = x;
+ prevframe_index = (y + motion_y) * stride + x + motion_x;
+ prevframe_x = x + motion_x;
+ while(pixel_count--) {
+
+ y_plane[curframe_index] = prev_y_plane[prevframe_index];
+ u_plane[curframe_index] = prev_u_plane[prevframe_index];
+ v_plane[curframe_index] = prev_v_plane[prevframe_index];
+
+ curframe_index++;
+ ADVANCE_CURFRAME_X();
+ prevframe_index++;
+ ADVANCE_PREVFRAME_X();
+ }
+ break;
+
+ default:
+ printf (" Xan WC3: Unhandled colorspace\n");
+ break;
+ }
+}
+
+static void xan_wc3_decode_frame(XanContext *s) {
+
+ int width = s->avctx->width;
+ int height = s->avctx->height;
+ int total_pixels = width * height;
+ unsigned char opcode;
+ unsigned char flag = 0;
+ int size = 0;
+ int motion_x, motion_y;
+ int x, y;
+
+ unsigned char *opcode_buffer = s->buffer1;
+ unsigned char *imagedata_buffer = s->buffer2;
+
+ /* pointers to segments inside the compressed chunk */
+ unsigned char *huffman_segment;
+ unsigned char *size_segment;
+ unsigned char *vector_segment;
+ unsigned char *imagedata_segment;
+
+ huffman_segment = s->buf + LE_16(&s->buf[0]);
+ size_segment = s->buf + LE_16(&s->buf[2]);
+ vector_segment = s->buf + LE_16(&s->buf[4]);
+ imagedata_segment = s->buf + LE_16(&s->buf[6]);
+
+ xan_huffman_decode(opcode_buffer, huffman_segment);
+
+ if (imagedata_segment[0] == 2)
+ xan_unpack(imagedata_buffer, &imagedata_segment[1]);
+ else
+ imagedata_buffer = &imagedata_segment[1];
+
+ /* use the decoded data segments to build the frame */
+ x = y = 0;
+ while (total_pixels) {
+
+ opcode = *opcode_buffer++;
+ size = 0;
+
+ switch (opcode) {
+
+ case 0:
+ flag ^= 1;
+ continue;
+
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ size = opcode;
+ break;
+
+ case 12:
+ case 13:
+ case 14:
+ case 15:
+ case 16:
+ case 17:
+ case 18:
+ size += (opcode - 10);
+ break;
+
+ case 9:
+ case 19:
+ size = *size_segment++;
+ break;
+
+ case 10:
+ case 20:
+ size = BE_16(&size_segment[0]);
+ size_segment += 2;
+ break;
+
+ case 11:
+ case 21:
+ size = (size_segment[0] << 16) | (size_segment[1] << 8) |
+ size_segment[2];
+ size_segment += 3;
+ break;
+ }
+
+ if (opcode < 12) {
+ flag ^= 1;
+ if (flag) {
+ /* run of (size) pixels is unchanged from last frame */
+ xan_wc3_copy_pixel_run(s, x, y, size, 0, 0);
+ } else {
+ /* output a run of pixels from imagedata_buffer */
+ xan_wc3_output_pixel_run(s, imagedata_buffer, x, y, size);
+ imagedata_buffer += size;
+ }
+ } else {
+ /* run-based motion compensation from last frame */
+ motion_x = (*vector_segment >> 4) & 0xF;
+ motion_y = *vector_segment & 0xF;
+ vector_segment++;
+
+ /* sign extension */
+ if (motion_x & 0x8)
+ motion_x |= 0xFFFFFFF0;
+ if (motion_y & 0x8)
+ motion_y |= 0xFFFFFFF0;
+
+ /* copy a run of pixels from the previous frame */
+ xan_wc3_copy_pixel_run(s, x, y, size, motion_x, motion_y);
+
+ flag = 0;
+ }
+
+ /* coordinate accounting */
+ total_pixels -= size;
+ while (size) {
+ if (x + size >= width) {
+ y++;
+ size -= (width - x);
+ x = 0;
+ } else {
+ x += size;
+ size = 0;
+ }
+ }
+ }
+
+ /* for PAL8, make the palette available on the way out */
+ if (s->avctx->pix_fmt == PIX_FMT_PAL8)
+ memcpy(s->current_frame.data[1], s->palette, PALETTE_COUNT * 4);
+}
+
+static void xan_wc4_decode_frame(XanContext *s) {
+}
+
+static int xan_decode_frame(AVCodecContext *avctx,
+ void *data, int *data_size,
+ uint8_t *buf, int buf_size)
+{
+ XanContext *s = avctx->priv_data;
+ AVPaletteControl *palette_control = (AVPaletteControl *)avctx->extradata;
+ int keyframe = 0;
+
+ if (palette_control->palette_changed) {
+ /* load the new palette and reset the palette control */
+ xan_wc3_build_palette(s, palette_control->palette);
+ palette_control->palette_changed = 0;
+ keyframe = 1;
+ }
+
+ if (avctx->get_buffer(avctx, &s->current_frame)) {
+ printf (" Xan Video: get_buffer() failed\n");
+ return -1;
+ }
+ s->current_frame.reference = 3;
+
+ s->buf = buf;
+ s->size = buf_size;
+
+ if (avctx->codec->id == CODEC_ID_XAN_WC3)
+ xan_wc3_decode_frame(s);
+ else if (avctx->codec->id == CODEC_ID_XAN_WC4)
+ xan_wc4_decode_frame(s);
+
+ /* release the last frame if it is allocated */
+ if (s->last_frame.data[0])
+ avctx->release_buffer(avctx, &s->last_frame);
+
+ /* shuffle frames */
+ s->last_frame = s->current_frame;
+
+ *data_size = sizeof(AVFrame);
+ *(AVFrame*)data = s->current_frame;
+
+ /* always report that the buffer was completely consumed */
+ return buf_size;
+}
+
+static int xan_decode_end(AVCodecContext *avctx)
+{
+ XanContext *s = avctx->priv_data;
+
+ /* release the last frame */
+ avctx->release_buffer(avctx, &s->last_frame);
+
+ av_free(s->buffer1);
+ av_free(s->buffer2);
+
+ return 0;
+}
+
+AVCodec xan_wc3_decoder = {
+ "xan_wc3",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_XAN_WC3,
+ sizeof(XanContext),
+ xan_decode_init,
+ NULL,
+ xan_decode_end,
+ xan_decode_frame,
+ CODEC_CAP_DR1,
+};
+
+/*
+AVCodec xan_wc4_decoder = {
+ "xan_wc4",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_XAN_WC4,
+ sizeof(XanContext),
+ xan_decode_init,
+ NULL,
+ xan_decode_end,
+ xan_decode_frame,
+ CODEC_CAP_DR1,
+};
+*/
diff --git a/src/libffmpeg/xine_decoder.c b/src/libffmpeg/xine_decoder.c
index 6627dafd4..b704734ba 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.130 2003/10/23 20:12:33 mroi Exp $
+ * $Id: xine_decoder.c,v 1.131 2003/10/27 15:24:38 tmmm Exp $
*
* xine decoder plugin using ffmpeg
*
@@ -230,7 +230,7 @@ static void init_video_codec (ff_video_decoder_t *this, xine_bmiheader *bih) {
* first frame. setting to -1 avoid enabling DR1 for them.
*/
this->context->pix_fmt = -1;
-
+
if( bih && bih->biSize > sizeof(xine_bmiheader) ) {
this->context->extradata_size = bih->biSize - sizeof(xine_bmiheader);
this->context->extradata = malloc(this->context->extradata_size);
@@ -238,6 +238,13 @@ static void init_video_codec (ff_video_decoder_t *this, xine_bmiheader *bih) {
(uint8_t *)bih + sizeof(xine_bmiheader),
this->context->extradata_size );
}
+ if ((this->codec->id == CODEC_ID_XAN_WC3) ||
+ (this->codec->id == CODEC_ID_INTERPLAY_VIDEO)) {
+ /* dupe certain decoders by giving them an empty palette; these
+ * decoders do not care about the palette during initialization */
+ this->context->extradata_size = sizeof(AVPaletteControl);
+ this->context->extradata = xine_xmalloc(this->context->extradata_size);
+ }
if(bih)
this->context->bits_per_sample = bih->biBitCount;
@@ -278,7 +285,8 @@ static void init_video_codec (ff_video_decoder_t *this, xine_bmiheader *bih) {
if((this->context->pix_fmt == PIX_FMT_RGBA32) ||
(this->context->pix_fmt == PIX_FMT_RGB565) ||
- (this->context->pix_fmt == PIX_FMT_RGB555)) {
+ (this->context->pix_fmt == PIX_FMT_RGB555) ||
+ (this->context->pix_fmt == PIX_FMT_PAL8)) {
this->output_format = XINE_IMGFMT_YUY2;
init_yuv_planes(&this->yuv, this->context->width, this->context->height);
} else {
@@ -643,6 +651,45 @@ static void ff_convert_frame(ff_video_decoder_t *this, vo_frame_t *img) {
yuv444_to_yuy2(&this->yuv, img->base[0], img->pitches[0]);
+ } else if (this->context->pix_fmt == PIX_FMT_PAL8) {
+
+ int x, plane_ptr = 0;
+ uint8_t *src;
+ uint8_t pixel;
+ uint32_t *palette32 = (uint32_t *)su; /* palette is in data[1] */
+ uint32_t rgb_color;
+ uint8_t r, g, b;
+ uint8_t y_palette[256];
+ uint8_t u_palette[256];
+ uint8_t v_palette[256];
+
+ for (x = 0; x < 256; x++) {
+ rgb_color = palette32[x];
+ b = rgb_color & 0xFF;
+ rgb_color >>= 8;
+ g = rgb_color & 0xFF;
+ rgb_color >>= 8;
+ r = rgb_color & 0xFF;
+ y_palette[x] = COMPUTE_Y(r, g, b);
+ u_palette[x] = COMPUTE_U(r, g, b);
+ v_palette[x] = COMPUTE_V(r, g, b);
+ }
+
+ for(y = 0; y < this->context->height; y++) {
+ src = sy;
+ for(x = 0; x < this->context->width; x++) {
+ pixel = *src++;
+
+ this->yuv.y[plane_ptr] = y_palette[pixel];
+ this->yuv.u[plane_ptr] = u_palette[pixel];
+ this->yuv.v[plane_ptr] = v_palette[pixel];
+ plane_ptr++;
+ }
+ sy += this->av_frame->linesize[0];
+ }
+
+ yuv444_to_yuy2(&this->yuv, img->base[0], img->pitches[0]);
+
} else {
for (y=0; y<this->context->height; y++) {
@@ -828,6 +875,56 @@ static void ff_decode_data (video_decoder_t *this_gen, buf_element_t *buf) {
this->stream->meta_info[XINE_META_INFO_VIDEOCODEC]
= strdup ("4XM (ffmpeg)");
break;
+ case BUF_VIDEO_CINEPAK:
+ this->codec = avcodec_find_decoder (CODEC_ID_CINEPAK);
+ this->stream->meta_info[XINE_META_INFO_VIDEOCODEC]
+ = strdup ("Cinepak (ffmpeg)");
+ break;
+ case BUF_VIDEO_MSVC:
+ this->codec = avcodec_find_decoder (CODEC_ID_MSVIDEO1);
+ this->stream->meta_info[XINE_META_INFO_VIDEOCODEC]
+ = strdup ("Microsoft Video 1 (ffmpeg)");
+ break;
+ case BUF_VIDEO_MSRLE:
+ this->codec = avcodec_find_decoder (CODEC_ID_MSRLE);
+ this->stream->meta_info[XINE_META_INFO_VIDEOCODEC]
+ = strdup ("Microsoft RLE (ffmpeg)");
+ break;
+ case BUF_VIDEO_RPZA:
+ this->codec = avcodec_find_decoder (CODEC_ID_RPZA);
+ this->stream->meta_info[XINE_META_INFO_VIDEOCODEC]
+ = strdup ("Apple Quicktime Video/RPZA (ffmpeg)");
+ break;
+ case BUF_VIDEO_CYUV:
+ this->codec = avcodec_find_decoder (CODEC_ID_CYUV);
+ this->stream->meta_info[XINE_META_INFO_VIDEOCODEC]
+ = strdup ("Creative YUV (ffmpeg)");
+ break;
+ case BUF_VIDEO_ROQ:
+ this->codec = avcodec_find_decoder (CODEC_ID_ROQ);
+ this->stream->meta_info[XINE_META_INFO_VIDEOCODEC]
+ = strdup ("Id Software RoQ (ffmpeg)");
+ break;
+ case BUF_VIDEO_IDCIN:
+ this->codec = avcodec_find_decoder (CODEC_ID_IDCIN);
+ this->stream->meta_info[XINE_META_INFO_VIDEOCODEC]
+ = strdup ("Id Software CIN (ffmpeg)");
+ break;
+ case BUF_VIDEO_WC3:
+ this->codec = avcodec_find_decoder (CODEC_ID_XAN_WC3);
+ this->stream->meta_info[XINE_META_INFO_VIDEOCODEC]
+ = strdup ("Xan (ffmpeg)");
+ break;
+ case BUF_VIDEO_VQA:
+ this->codec = avcodec_find_decoder (CODEC_ID_WS_VQA);
+ this->stream->meta_info[XINE_META_INFO_VIDEOCODEC]
+ = strdup ("Westwood Studios VQA (ffmpeg)");
+ break;
+ case BUF_VIDEO_INTERPLAY:
+ this->codec = avcodec_find_decoder (CODEC_ID_INTERPLAY_VIDEO);
+ this->stream->meta_info[XINE_META_INFO_VIDEOCODEC]
+ = strdup ("Interplay MVE (ffmpeg)");
+ break;
default:
printf ("ffmpeg: unknown video format (buftype: 0x%08X)\n",
buf->type & 0xFFFF0000);
@@ -843,13 +940,45 @@ static void ff_decode_data (video_decoder_t *this_gen, buf_element_t *buf) {
init_video_codec (this, (xine_bmiheader *)buf->content );
init_postprocess (this);
- } else if ((buf->decoder_flags & BUF_FLAG_SPECIAL) &&
- (buf->decoder_info[1] == BUF_SPECIAL_STSD_ATOM)) {
+ free(this->context->extradata);
+ this->context->extradata = NULL;
+ this->context->extradata_size = 0;
- this->context->extradata_size = buf->decoder_info[2];
- this->context->extradata = xine_xmalloc(buf->decoder_info[2]);
- memcpy(this->context->extradata, buf->decoder_info_ptr[2],
- buf->decoder_info[2]);
+ } else if (buf->decoder_flags & BUF_FLAG_SPECIAL) {
+
+ /* take care of all the various types of special buffers */
+
+ /* first, free any previous extradata chunk */
+ free(this->context->extradata);
+ this->context->extradata = NULL;
+ this->context->extradata_size = 0;
+
+ if (buf->decoder_info[1] == BUF_SPECIAL_STSD_ATOM) {
+
+ this->context->extradata_size = buf->decoder_info[2];
+ this->context->extradata = xine_xmalloc(buf->decoder_info[2]);
+ memcpy(this->context->extradata, buf->decoder_info_ptr[2],
+ buf->decoder_info[2]);
+
+ } else if (buf->decoder_info[1] == BUF_SPECIAL_PALETTE) {
+
+ int i;
+ palette_entry_t *demuxer_palette;
+ AVPaletteControl *decoder_palette;
+
+ this->context->extradata_size = sizeof(AVPaletteControl);
+ this->context->extradata = xine_xmalloc(this->context->extradata_size);
+
+ decoder_palette = (AVPaletteControl *)this->context->extradata;
+ demuxer_palette = (palette_entry_t *)buf->decoder_info_ptr[2];
+
+ for (i = 0; i < buf->decoder_info[2]; i++) {
+ decoder_palette->palette[i * 3 + 0] = demuxer_palette[i].r;
+ decoder_palette->palette[i * 3 + 1] = demuxer_palette[i].g;
+ decoder_palette->palette[i * 3 + 2] = demuxer_palette[i].b;
+ }
+ decoder_palette->palette_changed = 1;
+ }
} else if (this->decoder_ok) {
@@ -916,7 +1045,7 @@ static void ff_decode_data (video_decoder_t *this_gen, buf_element_t *buf) {
len = this->size;
got_picture = 1;
} else
- len = avcodec_decode_video (this->context, this->av_frame,
+ len = avcodec_decode_video (this->context, this->av_frame,
&got_picture, &this->buf[offset],
this->size);
if (len<0) {
@@ -943,7 +1072,7 @@ static void ff_decode_data (video_decoder_t *this_gen, buf_element_t *buf) {
printf ("ffmpeg: got a picture\n");
#endif
- this->aspect_ratio = this->context->aspect_ratio;
+ this->aspect_ratio = av_q2d (this->context->sample_aspect_ratio);
if(this->av_frame->type == FF_BUFFER_TYPE_USER){
img = (vo_frame_t*)this->av_frame->opaque;
@@ -1079,9 +1208,9 @@ void avcodec_register_all(void)
register_avcodec(&wmav1_decoder);
register_avcodec(&wmav2_decoder);
register_avcodec(&indeo3_decoder);
- register_avcodec(&mpeg_decoder);
+ register_avcodec(&mpeg1video_decoder);
register_avcodec(&dvvideo_decoder);
- register_avcodec(&dvaudio_decoder);
+ register_avcodec(&pcm_s16le_decoder);
register_avcodec(&mjpeg_decoder);
register_avcodec(&mjpegb_decoder);
register_avcodec(&mp2_decoder);
@@ -1095,6 +1224,26 @@ void avcodec_register_all(void)
register_avcodec(&fourxm_decoder);
register_avcodec(&ra_144_decoder);
register_avcodec(&ra_288_decoder);
+ register_avcodec(&adpcm_ms_decoder);
+ register_avcodec(&adpcm_ima_qt_decoder);
+ register_avcodec(&adpcm_ima_wav_decoder);
+ register_avcodec(&adpcm_ima_dk3_decoder);
+ register_avcodec(&adpcm_ima_dk4_decoder);
+ register_avcodec(&adpcm_ima_ws_decoder);
+ register_avcodec(&adpcm_xa_decoder);
+ register_avcodec(&pcm_alaw_decoder);
+ register_avcodec(&pcm_mulaw_decoder);
+ register_avcodec(&roq_dpcm_decoder);
+ register_avcodec(&interplay_dpcm_decoder);
+ register_avcodec(&cinepak_decoder);
+ register_avcodec(&msvideo1_decoder);
+ register_avcodec(&msrle_decoder);
+ register_avcodec(&rpza_decoder);
+ register_avcodec(&roq_decoder);
+ register_avcodec(&idcin_decoder);
+ register_avcodec(&xan_wc3_decoder);
+ register_avcodec(&vqa_decoder);
+ register_avcodec(&interplay_video_decoder);
}
static void ff_dispose (video_decoder_t *this_gen) {
@@ -1120,7 +1269,8 @@ static void ff_dispose (video_decoder_t *this_gen) {
if((this->context) &&
((this->context->pix_fmt == PIX_FMT_RGBA32) ||
(this->context->pix_fmt == PIX_FMT_RGB565) ||
- (this->context->pix_fmt == PIX_FMT_RGB555)))
+ (this->context->pix_fmt == PIX_FMT_RGB555) ||
+ (this->context->pix_fmt == PIX_FMT_PAL8)))
free_yuv_planes(&this->yuv);
if( this->context )
@@ -1279,6 +1429,61 @@ static void ff_audio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf)
this->stream->meta_info[XINE_META_INFO_AUDIOCODEC]
= strdup ("MP3 (ffmpeg)");
break;
+ case BUF_AUDIO_MSADPCM:
+ this->codec = avcodec_find_decoder (CODEC_ID_ADPCM_MS);
+ this->stream->meta_info[XINE_META_INFO_AUDIOCODEC]
+ = strdup ("MS ADPCM (ffmpeg)");
+ break;
+ case BUF_AUDIO_QTIMAADPCM:
+ this->codec = avcodec_find_decoder (CODEC_ID_ADPCM_IMA_QT);
+ this->stream->meta_info[XINE_META_INFO_AUDIOCODEC]
+ = strdup ("QT IMA ADPCM (ffmpeg)");
+ break;
+ case BUF_AUDIO_MSIMAADPCM:
+ this->codec = avcodec_find_decoder (CODEC_ID_ADPCM_IMA_WAV);
+ this->stream->meta_info[XINE_META_INFO_AUDIOCODEC]
+ = strdup ("MS IMA ADPCM (ffmpeg)");
+ break;
+ case BUF_AUDIO_DK3ADPCM:
+ this->codec = avcodec_find_decoder (CODEC_ID_ADPCM_IMA_DK3);
+ this->stream->meta_info[XINE_META_INFO_AUDIOCODEC]
+ = strdup ("Duck DK3 ADPCM (ffmpeg)");
+ break;
+ case BUF_AUDIO_DK4ADPCM:
+ this->codec = avcodec_find_decoder (CODEC_ID_ADPCM_IMA_DK4);
+ this->stream->meta_info[XINE_META_INFO_AUDIOCODEC]
+ = strdup ("Duck DK4 ADPCM (ffmpeg)");
+ break;
+ case BUF_AUDIO_VQA_IMA:
+ this->codec = avcodec_find_decoder (CODEC_ID_ADPCM_IMA_WS);
+ this->stream->meta_info[XINE_META_INFO_AUDIOCODEC]
+ = strdup ("Westwood Studios IMA (ffmpeg)");
+ break;
+ case BUF_AUDIO_XA_ADPCM:
+ this->codec = avcodec_find_decoder (CODEC_ID_ADPCM_XA);
+ this->stream->meta_info[XINE_META_INFO_AUDIOCODEC]
+ = strdup ("CD-ROM/XA ADPCM (ffmpeg)");
+ break;
+ case BUF_AUDIO_MULAW:
+ this->codec = avcodec_find_decoder (CODEC_ID_PCM_MULAW);
+ this->stream->meta_info[XINE_META_INFO_AUDIOCODEC]
+ = strdup ("mu-law logarithmic PCM (ffmpeg)");
+ break;
+ case BUF_AUDIO_ALAW:
+ this->codec = avcodec_find_decoder (CODEC_ID_PCM_ALAW);
+ this->stream->meta_info[XINE_META_INFO_AUDIOCODEC]
+ = strdup ("A-law logarithmic PCM (ffmpeg)");
+ break;
+ case BUF_AUDIO_ROQ:
+ this->codec = avcodec_find_decoder (CODEC_ID_ROQ_DPCM);
+ this->stream->meta_info[XINE_META_INFO_AUDIOCODEC]
+ = strdup ("RoQ DPCM (ffmpeg)");
+ break;
+ case BUF_AUDIO_INTERPLAY:
+ this->codec = avcodec_find_decoder (CODEC_ID_INTERPLAY_DPCM);
+ this->stream->meta_info[XINE_META_INFO_AUDIOCODEC]
+ = strdup ("Interplay DPCM (ffmpeg)");
+ break;
}
if (!this->codec) {
@@ -1527,8 +1732,18 @@ static uint32_t supported_video_types[] = {
BUF_VIDEO_MPEG,
BUF_VIDEO_DV,
BUF_VIDEO_HUFFYUV,
-/* BUF_VIDEO_VP31,*/
+ BUF_VIDEO_VP31,
BUF_VIDEO_4XM,
+ BUF_VIDEO_CINEPAK,
+ BUF_VIDEO_MSVC,
+ BUF_VIDEO_MSRLE,
+ BUF_VIDEO_RPZA,
+ BUF_VIDEO_CYUV,
+ BUF_VIDEO_ROQ,
+ BUF_VIDEO_IDCIN,
+ BUF_VIDEO_WC3,
+ BUF_VIDEO_VQA,
+ BUF_VIDEO_INTERPLAY,
0
};
@@ -1543,6 +1758,17 @@ static uint32_t supported_audio_types[] = {
BUF_AUDIO_DV,
BUF_AUDIO_14_4,
BUF_AUDIO_28_8,
+ BUF_AUDIO_MULAW,
+ BUF_AUDIO_ALAW,
+ BUF_AUDIO_MSADPCM,
+ BUF_AUDIO_QTIMAADPCM,
+ BUF_AUDIO_MSIMAADPCM,
+ BUF_AUDIO_DK3ADPCM,
+ BUF_AUDIO_DK4ADPCM,
+ BUF_AUDIO_XA_ADPCM,
+ BUF_AUDIO_ROQ,
+ BUF_AUDIO_INTERPLAY,
+ BUF_AUDIO_VQA_IMA,
/* BUF_AUDIO_MPEG, */
0
};