| 659 | } |
| 660 | |
| 661 | static av_always_inline void mpeg1_encode_mb_internal(MPVEncContext *const s, |
| 662 | const int16_t block[8][64], |
| 663 | int motion_x, int motion_y, |
| 664 | int mb_block_count, |
| 665 | int chroma_y_shift) |
| 666 | { |
| 667 | /* MPEG-1 is always 420. */ |
| 668 | #define IS_MPEG1(s) (chroma_y_shift == 1 && (s)->c.codec_id == AV_CODEC_ID_MPEG1VIDEO) |
| 669 | int i, cbp; |
| 670 | const int mb_x = s->c.mb_x; |
| 671 | const int mb_y = s->c.mb_y; |
| 672 | const int first_mb = mb_x == s->c.resync_mb_x && mb_y == s->c.resync_mb_y; |
| 673 | |
| 674 | /* compute cbp */ |
| 675 | cbp = 0; |
| 676 | for (i = 0; i < mb_block_count; i++) |
| 677 | if (s->c.block_last_index[i] >= 0) |
| 678 | cbp |= 1 << (mb_block_count - 1 - i); |
| 679 | |
| 680 | if (cbp == 0 && !first_mb && s->c.mv_type == MV_TYPE_16X16 && |
| 681 | (mb_x != s->c.mb_width - 1 || |
| 682 | (mb_y != s->c.end_mb_y - 1 && IS_MPEG1(s))) && |
| 683 | ((s->c.pict_type == AV_PICTURE_TYPE_P && (motion_x | motion_y) == 0) || |
| 684 | (s->c.pict_type == AV_PICTURE_TYPE_B && s->c.mv_dir == s->last_mv_dir && |
| 685 | (((s->c.mv_dir & MV_DIR_FORWARD) |
| 686 | ? ((s->c.mv[0][0][0] - s->c.last_mv[0][0][0]) | |
| 687 | (s->c.mv[0][0][1] - s->c.last_mv[0][0][1])) : 0) | |
| 688 | ((s->c.mv_dir & MV_DIR_BACKWARD) |
| 689 | ? ((s->c.mv[1][0][0] - s->c.last_mv[1][0][0]) | |
| 690 | (s->c.mv[1][0][1] - s->c.last_mv[1][0][1])) : 0)) == 0))) { |
| 691 | s->mb_skip_run++; |
| 692 | s->c.qscale -= s->dquant; |
| 693 | s->misc_bits++; |
| 694 | s->last_bits++; |
| 695 | if (s->c.pict_type == AV_PICTURE_TYPE_P) { |
| 696 | s->c.last_mv[0][0][0] = |
| 697 | s->c.last_mv[0][0][1] = |
| 698 | s->c.last_mv[0][1][0] = |
| 699 | s->c.last_mv[0][1][1] = 0; |
| 700 | } |
| 701 | } else { |
| 702 | if (first_mb) { |
| 703 | av_assert0(s->mb_skip_run == 0); |
| 704 | encode_mb_skip_run(s, s->c.mb_x); |
| 705 | } else { |
| 706 | encode_mb_skip_run(s, s->mb_skip_run); |
| 707 | } |
| 708 | |
| 709 | if (s->c.pict_type == AV_PICTURE_TYPE_I) { |
| 710 | if (s->dquant && cbp) { |
| 711 | /* macroblock_type: macroblock_quant = 1 */ |
| 712 | put_mb_modes(s, 2, 1, 0, 0); |
| 713 | put_qscale(s); |
| 714 | } else { |
| 715 | /* macroblock_type: macroblock_quant = 0 */ |
| 716 | put_mb_modes(s, 1, 1, 0, 0); |
| 717 | s->c.qscale -= s->dquant; |
| 718 | } |
no test coverage detected