comparison mpeg12.c @ 281:1fc96b02142e libavcodec

mpeg4 aspect_ratio_info in AVCodecContext (requested by alex) experimental (& faster) motion estimation squished a dirty uninitialized var bug mpeg1 fcode>1 support
author michaelni
date Fri, 22 Mar 2002 23:22:08 +0000
parents 5cb2978e701f
children 73a9ce3d9715
comparison
equal deleted inserted replaced
280:3dc1ca4ba717 281:1fc96b02142e
48 int n); 48 int n);
49 static int mpeg2_decode_block_intra(MpegEncContext *s, 49 static int mpeg2_decode_block_intra(MpegEncContext *s,
50 DCTELEM *block, 50 DCTELEM *block,
51 int n); 51 int n);
52 static int mpeg_decode_motion(MpegEncContext *s, int fcode, int pred); 52 static int mpeg_decode_motion(MpegEncContext *s, int fcode, int pred);
53
54 static UINT16 mv_penalty[MAX_FCODE][MAX_MV*2+1];
55 static UINT8 fcode_tab[MAX_MV*2+1];
53 56
54 static void put_header(MpegEncContext *s, int header) 57 static void put_header(MpegEncContext *s, int header)
55 { 58 {
56 align_put_bits(&s->pb); 59 align_put_bits(&s->pb);
57 put_bits(&s->pb, 16, header>>16); 60 put_bits(&s->pb, 16, header>>16);
351 put_bits(&s->pb, bit_size, bits); 354 put_bits(&s->pb, bit_size, bits);
352 } 355 }
353 } 356 }
354 } 357 }
355 358
359 void mpeg1_encode_init(MpegEncContext *s)
360 {
361 static int done=0;
362 if(!done){
363 int f_code;
364 int mv;
365
366 done=1;
367 for(f_code=1; f_code<=MAX_FCODE; f_code++){
368 for(mv=-MAX_MV; mv<=MAX_MV; mv++){
369 int len;
370
371 if(mv==0) len= mbMotionVectorTable[0][1];
372 else{
373 int val, bit_size, range, code;
374
375 bit_size = s->f_code - 1;
376 range = 1 << bit_size;
377
378 val=mv;
379 if (val < 0)
380 val = -val;
381 val--;
382 code = (val >> bit_size) + 1;
383 if(code<17){
384 len= mbMotionVectorTable[code][1] + 1 + bit_size;
385 }else{
386 len= mbMotionVectorTable[16][1] + 2 + bit_size;
387 }
388 }
389
390 mv_penalty[f_code][mv+MAX_MV]= len;
391 }
392 }
393
394
395 for(f_code=MAX_FCODE; f_code>0; f_code--){
396 for(mv=-(8<<f_code); mv<(8<<f_code); mv++){
397 fcode_tab[mv+MAX_MV]= f_code;
398 }
399 }
400 }
401 s->mv_penalty= mv_penalty;
402
403 s->fcode_tab= fcode_tab;
404 }
405
356 static inline void encode_dc(MpegEncContext *s, int diff, int component) 406 static inline void encode_dc(MpegEncContext *s, int diff, int component)
357 { 407 {
358 if (component == 0) { 408 if (component == 0) {
359 put_bits( 409 put_bits(
360 &s->pb, 410 &s->pb,