Revision 8f8402e4 libavcodec/mpeg12.c

View differences:

libavcodec/mpeg12.c
184 184
    put_bits(&s->pb, 1, 1); 
185 185
}
186 186

  
187
void mpeg1_encode_picture_header(MpegEncContext *s, int picture_number)
187
static void common_init(MpegEncContext *s)
188 188
{
189
    static int done=0;
190

  
191
    if (!done) {
192
	int i;
193
        done = 1;
194
        init_rl(&rl_mpeg1);
195
	
196
	for(i=0; i<64; i++)
197
	{
198
		mpeg1_max_level[0][i]= rl_mpeg1.max_level[0][i];
199
		mpeg1_index_run[0][i]= rl_mpeg1.index_run[0][i];
200
	}
201

  
202
	/* build unified dc encoding tables */
203
	for(i=-255; i<256; i++)
204
	{
205
		int adiff, index;
206
		int bits, code;
207
		int diff=i;
208

  
209
		adiff = ABS(diff);
210
		if(diff<0) diff--;
211
		index = vlc_dc_table[adiff];
189
    s->y_dc_scale_table=
190
    s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
191
}
212 192

  
213
		bits= vlc_dc_lum_bits[index] + index;
214
		code= (vlc_dc_lum_code[index]<<index) + (diff & ((1 << index) - 1));
215
		mpeg1_lum_dc_uni[i+255]= bits + (code<<8);
216
		
217
		bits= vlc_dc_chroma_bits[index] + index;
218
		code= (vlc_dc_chroma_code[index]<<index) + (diff & ((1 << index) - 1));
219
		mpeg1_chr_dc_uni[i+255]= bits + (code<<8);
220
	}
221
    }
193
void mpeg1_encode_picture_header(MpegEncContext *s, int picture_number)
194
{
222 195
    mpeg1_encode_sequence_header(s);
223 196

  
224 197
    /* mpeg1 picture header */
......
354 327
    }
355 328
}
356 329

  
357
void mpeg1_encode_init(MpegEncContext *s)
330
void ff_mpeg1_encode_init(MpegEncContext *s)
358 331
{
359 332
    static int done=0;
333

  
334
    common_init(s);
335

  
360 336
    if(!done){
361 337
        int f_code;
362 338
        int mv;
339
	int i;
363 340

  
364 341
        done=1;
342
        init_rl(&rl_mpeg1);
343
	
344
	for(i=0; i<64; i++)
345
	{
346
		mpeg1_max_level[0][i]= rl_mpeg1.max_level[0][i];
347
		mpeg1_index_run[0][i]= rl_mpeg1.index_run[0][i];
348
	}
349

  
350
	/* build unified dc encoding tables */
351
	for(i=-255; i<256; i++)
352
	{
353
		int adiff, index;
354
		int bits, code;
355
		int diff=i;
356

  
357
		adiff = ABS(diff);
358
		if(diff<0) diff--;
359
		index = vlc_dc_table[adiff];
360

  
361
		bits= vlc_dc_lum_bits[index] + index;
362
		code= (vlc_dc_lum_code[index]<<index) + (diff & ((1 << index) - 1));
363
		mpeg1_lum_dc_uni[i+255]= bits + (code<<8);
364
		
365
		bits= vlc_dc_chroma_bits[index] + index;
366
		code= (vlc_dc_chroma_code[index]<<index) + (diff & ((1 << index) - 1));
367
		mpeg1_chr_dc_uni[i+255]= bits + (code<<8);
368
	}
369

  
365 370
        for(f_code=1; f_code<=MAX_FCODE; f_code++){
366 371
            for(mv=-MAX_MV; mv<=MAX_MV; mv++){
367 372
                int len;
......
403 408
    s->intra_quant_bias= 3<<(QUANT_BIAS_SHIFT-3); //(a + x*3/8)/x
404 409
    s->inter_quant_bias= 0;
405 410
}
406
 
411

  
407 412
static inline void encode_dc(MpegEncContext *s, int diff, int component)
408 413
{
409 414
    if (component == 0) {
......
1183 1188
static int mpeg_decode_init(AVCodecContext *avctx)
1184 1189
{
1185 1190
    Mpeg1Context *s = avctx->priv_data;
1191
    
1192
    common_init(&s->mpeg_enc_ctx);
1186 1193

  
1187 1194
    s->header_state = 0xff;
1188 1195
    s->mpeg_enc_ctx_allocated = 0;

Also available in: Unified diff