Revision 11ce8834 libavcodec/mpeg12.c

View differences:

libavcodec/mpeg12.c
51 51
                                    int n);
52 52
static int mpeg_decode_motion(MpegEncContext *s, int fcode, int pred);
53 53

  
54
static UINT16 mv_penalty[MAX_FCODE][MAX_MV*2+1];
55
static UINT8 fcode_tab[MAX_MV*2+1];
56

  
54 57
static void put_header(MpegEncContext *s, int header)
55 58
{
56 59
    align_put_bits(&s->pb);
......
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 406
static inline void encode_dc(MpegEncContext *s, int diff, int component)
357 407
{
358 408
    if (component == 0) {

Also available in: Unified diff