diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2002-03-22 23:22:08 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2002-03-22 23:22:08 +0000 |
commit | 11ce88346b1ae4da21b581baf1b4eb784d842547 (patch) | |
tree | bffaf9c06980445db1dc0cf44399526faee72316 /libavcodec/mpeg12.c | |
parent | c5b1c10a0e1ed783674b24d787797ffba9bdffc0 (diff) | |
download | ffmpeg-11ce88346b1ae4da21b581baf1b4eb784d842547.tar.gz |
mpeg4 aspect_ratio_info in AVCodecContext (requested by alex)
experimental (& faster) motion estimation
squished a dirty uninitialized var bug
mpeg1 fcode>1 support
Originally committed as revision 349 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/mpeg12.c')
-rw-r--r-- | libavcodec/mpeg12.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index 417f595644..fba90e7144 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -51,6 +51,9 @@ static int mpeg2_decode_block_intra(MpegEncContext *s, int n); static int mpeg_decode_motion(MpegEncContext *s, int fcode, int pred); +static UINT16 mv_penalty[MAX_FCODE][MAX_MV*2+1]; +static UINT8 fcode_tab[MAX_MV*2+1]; + static void put_header(MpegEncContext *s, int header) { align_put_bits(&s->pb); @@ -353,6 +356,53 @@ static void mpeg1_encode_motion(MpegEncContext *s, int val) } } +void mpeg1_encode_init(MpegEncContext *s) +{ + static int done=0; + if(!done){ + int f_code; + int mv; + + done=1; + for(f_code=1; f_code<=MAX_FCODE; f_code++){ + for(mv=-MAX_MV; mv<=MAX_MV; mv++){ + int len; + + if(mv==0) len= mbMotionVectorTable[0][1]; + else{ + int val, bit_size, range, code; + + bit_size = s->f_code - 1; + range = 1 << bit_size; + + val=mv; + if (val < 0) + val = -val; + val--; + code = (val >> bit_size) + 1; + if(code<17){ + len= mbMotionVectorTable[code][1] + 1 + bit_size; + }else{ + len= mbMotionVectorTable[16][1] + 2 + bit_size; + } + } + + mv_penalty[f_code][mv+MAX_MV]= len; + } + } + + + for(f_code=MAX_FCODE; f_code>0; f_code--){ + for(mv=-(8<<f_code); mv<(8<<f_code); mv++){ + fcode_tab[mv+MAX_MV]= f_code; + } + } + } + s->mv_penalty= mv_penalty; + + s->fcode_tab= fcode_tab; +} + static inline void encode_dc(MpegEncContext *s, int diff, int component) { if (component == 0) { |