Mercurial > libavcodec.hg
comparison h263.c @ 286:91f7c38f5f37 libavcodec
statistics for 2-pass encoding
author | michaelni |
---|---|
date | Sat, 23 Mar 2002 17:43:30 +0000 |
parents | 39b78867b71f |
children | 32a3dcce2e9b |
comparison
equal
deleted
inserted
replaced
285:39b78867b71f | 286:91f7c38f5f37 |
---|---|
243 void mpeg4_encode_mb(MpegEncContext * s, | 243 void mpeg4_encode_mb(MpegEncContext * s, |
244 DCTELEM block[6][64], | 244 DCTELEM block[6][64], |
245 int motion_x, int motion_y) | 245 int motion_x, int motion_y) |
246 { | 246 { |
247 int cbpc, cbpy, i, cbp, pred_x, pred_y; | 247 int cbpc, cbpy, i, cbp, pred_x, pred_y; |
248 int bits; | |
248 | 249 |
249 // printf("**mb x=%d y=%d\n", s->mb_x, s->mb_y); | 250 // printf("**mb x=%d y=%d\n", s->mb_x, s->mb_y); |
250 if (!s->mb_intra) { | 251 if (!s->mb_intra) { |
251 /* compute cbp */ | 252 /* compute cbp */ |
252 cbp = 0; | 253 cbp = 0; |
255 cbp |= 1 << (5 - i); | 256 cbp |= 1 << (5 - i); |
256 } | 257 } |
257 if ((cbp | motion_x | motion_y) == 0) { | 258 if ((cbp | motion_x | motion_y) == 0) { |
258 /* skip macroblock */ | 259 /* skip macroblock */ |
259 put_bits(&s->pb, 1, 1); | 260 put_bits(&s->pb, 1, 1); |
261 s->misc_bits++; | |
262 s->last_bits++; | |
263 s->skip_count++; | |
260 return; | 264 return; |
261 } | 265 } |
262 put_bits(&s->pb, 1, 0); /* mb coded */ | 266 put_bits(&s->pb, 1, 0); /* mb coded */ |
263 cbpc = cbp & 3; | 267 cbpc = cbp & 3; |
264 put_bits(&s->pb, | 268 put_bits(&s->pb, |
265 inter_MCBPC_bits[cbpc], | 269 inter_MCBPC_bits[cbpc], |
266 inter_MCBPC_code[cbpc]); | 270 inter_MCBPC_code[cbpc]); |
267 cbpy = cbp >> 2; | 271 cbpy = cbp >> 2; |
268 cbpy ^= 0xf; | 272 cbpy ^= 0xf; |
269 put_bits(&s->pb, cbpy_tab[cbpy][1], cbpy_tab[cbpy][0]); | 273 put_bits(&s->pb, cbpy_tab[cbpy][1], cbpy_tab[cbpy][0]); |
274 | |
275 bits= get_bit_count(&s->pb); | |
276 s->misc_bits+= bits - s->last_bits; | |
277 s->last_bits=bits; | |
270 | 278 |
271 /* motion vectors: 16x16 mode only now */ | 279 /* motion vectors: 16x16 mode only now */ |
272 h263_pred_motion(s, 0, &pred_x, &pred_y); | 280 h263_pred_motion(s, 0, &pred_x, &pred_y); |
273 | 281 |
274 h263_encode_motion(s, motion_x - pred_x); | 282 h263_encode_motion(s, motion_x - pred_x); |
275 h263_encode_motion(s, motion_y - pred_y); | 283 h263_encode_motion(s, motion_y - pred_y); |
276 | 284 |
285 bits= get_bit_count(&s->pb); | |
286 s->mv_bits+= bits - s->last_bits; | |
287 s->last_bits=bits; | |
288 | |
277 /* encode each block */ | 289 /* encode each block */ |
278 for (i = 0; i < 6; i++) { | 290 for (i = 0; i < 6; i++) { |
279 mpeg4_encode_block(s, block[i], i, 0, zigzag_direct); | 291 mpeg4_encode_block(s, block[i], i, 0, zigzag_direct); |
280 } | 292 } |
293 bits= get_bit_count(&s->pb); | |
294 s->p_tex_bits+= bits - s->last_bits; | |
295 s->last_bits=bits; | |
296 s->p_count++; | |
281 } else { | 297 } else { |
282 int dc_diff[6]; //dc values with the dc prediction subtracted | 298 int dc_diff[6]; //dc values with the dc prediction subtracted |
283 int dir[6]; //prediction direction | 299 int dir[6]; //prediction direction |
284 int zigzag_last_index[6]; | 300 int zigzag_last_index[6]; |
285 UINT8 *scan_table[6]; | 301 UINT8 *scan_table[6]; |
338 } | 354 } |
339 put_bits(&s->pb, 1, s->ac_pred); | 355 put_bits(&s->pb, 1, s->ac_pred); |
340 cbpy = cbp >> 2; | 356 cbpy = cbp >> 2; |
341 put_bits(&s->pb, cbpy_tab[cbpy][1], cbpy_tab[cbpy][0]); | 357 put_bits(&s->pb, cbpy_tab[cbpy][1], cbpy_tab[cbpy][0]); |
342 | 358 |
359 bits= get_bit_count(&s->pb); | |
360 s->misc_bits+= bits - s->last_bits; | |
361 s->last_bits=bits; | |
362 | |
343 /* encode each block */ | 363 /* encode each block */ |
344 for (i = 0; i < 6; i++) { | 364 for (i = 0; i < 6; i++) { |
345 mpeg4_encode_block(s, block[i], i, dc_diff[i], scan_table[i]); | 365 mpeg4_encode_block(s, block[i], i, dc_diff[i], scan_table[i]); |
346 } | 366 } |
367 | |
368 bits= get_bit_count(&s->pb); | |
369 s->i_tex_bits+= bits - s->last_bits; | |
370 s->last_bits=bits; | |
371 s->i_count++; | |
347 | 372 |
348 /* restore ac coeffs & last_index stuff if we messed them up with the prediction */ | 373 /* restore ac coeffs & last_index stuff if we messed them up with the prediction */ |
349 if(s->ac_pred){ | 374 if(s->ac_pred){ |
350 for(i=0; i<6; i++){ | 375 for(i=0; i<6; i++){ |
351 int j; | 376 int j; |