MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / msmpeg4_encode_mb

Function msmpeg4_encode_mb

libavcodec/msmpeg4enc.c:377–500  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

375}
376
377static void msmpeg4_encode_mb(MPVEncContext *const s,
378 int16_t block[][64],
379 int motion_x, int motion_y)
380{
381 MSMPEG4EncContext *const ms = mpv_to_msmpeg4(s);
382 int cbp, coded_cbp, i;
383 int pred_x, pred_y;
384
385 ff_msmpeg4_handle_slices(s);
386
387 if (!s->c.mb_intra) {
388 /* compute cbp */
389 cbp = 0;
390 for (i = 0; i < 6; i++) {
391 if (s->c.block_last_index[i] >= 0)
392 cbp |= 1 << (5 - i);
393 }
394 if (ms->use_skip_mb_code && (cbp | motion_x | motion_y) == 0) {
395 /* skip macroblock */
396 put_bits(&s->pb, 1, 1);
397 s->last_bits++;
398 s->misc_bits++;
399
400 return;
401 }
402 if (ms->use_skip_mb_code)
403 put_bits(&s->pb, 1, 0); /* mb coded */
404
405 if (s->c.msmpeg4_version <= MSMP4_V2) {
406 put_bits(&s->pb,
407 ff_v2_mb_type[cbp&3][1],
408 ff_v2_mb_type[cbp&3][0]);
409 if((cbp&3) != 3) coded_cbp= cbp ^ 0x3C;
410 else coded_cbp= cbp;
411
412 put_bits(&s->pb,
413 ff_h263_cbpy_tab[coded_cbp>>2][1],
414 ff_h263_cbpy_tab[coded_cbp>>2][0]);
415
416 s->misc_bits += get_bits_diff(s);
417
418 ff_h263_pred_motion(&s->c, 0, 0, &pred_x, &pred_y);
419 msmpeg4v2_encode_motion(s, motion_x - pred_x);
420 msmpeg4v2_encode_motion(s, motion_y - pred_y);
421 }else{
422 put_bits(&s->pb,
423 ff_table_mb_non_intra[cbp + 64][1],
424 ff_table_mb_non_intra[cbp + 64][0]);
425
426 s->misc_bits += get_bits_diff(s);
427
428 /* motion vector */
429 ff_h263_pred_motion(&s->c, 0, 0, &pred_x, &pred_y);
430 ff_msmpeg4_encode_motion(ms, motion_x - pred_x,
431 motion_y - pred_y);
432 }
433
434 s->mv_bits += get_bits_diff(s);

Callers

nothing calls this directly

Calls 9

ff_msmpeg4_handle_slicesFunction · 0.85
get_bits_diffFunction · 0.85
ff_h263_pred_motionFunction · 0.85
msmpeg4v2_encode_motionFunction · 0.85
ff_msmpeg4_encode_motionFunction · 0.85
ff_msmpeg4_encode_blockFunction · 0.85
mpv_to_msmpeg4Function · 0.70
put_bitsFunction · 0.70

Tested by

no test coverage detected