Mercurial > libavcodec.hg
comparison mpeg12.c @ 1708:dea5b2946999 libavcodec
interlaced motion estimation
interlaced mpeg2 encoding
P & B frames
rate distored interlaced mb decission
alternate scantable support
4mv encoding fixes (thats also why the regression tests change)
passing height to most dsp functions
interlaced mpeg4 encoding (no direct mode MBs yet)
various related cleanups
disabled old motion estimaton algorithms (log, full, ...) they will either be fixed or removed
author | michael |
---|---|
date | Tue, 30 Dec 2003 16:07:57 +0000 |
parents | 3ba5c493db6f |
children | 4a68b20eeb2c |
comparison
equal
deleted
inserted
replaced
1707:027545a2fdbe | 1708:dea5b2946999 |
---|---|
27 #include "dsputil.h" | 27 #include "dsputil.h" |
28 #include "mpegvideo.h" | 28 #include "mpegvideo.h" |
29 | 29 |
30 #include "mpeg12data.h" | 30 #include "mpeg12data.h" |
31 | 31 |
32 //#undef NDEBUG | |
33 //#include <assert.h> | |
34 | |
32 | 35 |
33 /* Start codes. */ | 36 /* Start codes. */ |
34 #define SEQ_END_CODE 0x000001b7 | 37 #define SEQ_END_CODE 0x000001b7 |
35 #define SEQ_START_CODE 0x000001b3 | 38 #define SEQ_START_CODE 0x000001b3 |
36 #define GOP_START_CODE 0x000001b8 | 39 #define GOP_START_CODE 0x000001b8 |
474 s->mb_y=0; | 477 s->mb_y=0; |
475 ff_mpeg1_encode_slice_header(s); | 478 ff_mpeg1_encode_slice_header(s); |
476 } | 479 } |
477 | 480 |
478 static inline void put_mb_modes(MpegEncContext *s, int n, int bits, | 481 static inline void put_mb_modes(MpegEncContext *s, int n, int bits, |
479 int has_mv) | 482 int has_mv, int field_motion) |
480 { | 483 { |
481 put_bits(&s->pb, n, bits); | 484 put_bits(&s->pb, n, bits); |
482 if (!s->frame_pred_frame_dct) { | 485 if (!s->frame_pred_frame_dct) { |
483 if (has_mv) | 486 if (has_mv) |
484 put_bits(&s->pb, 2, 2); /* motion_type: frame */ | 487 put_bits(&s->pb, 2, 2 - field_motion); /* motion_type: frame/field */ |
485 put_bits(&s->pb, 1, s->interlaced_dct); | 488 put_bits(&s->pb, 1, s->interlaced_dct); |
486 } | 489 } |
487 } | 490 } |
488 | 491 |
489 void mpeg1_encode_mb(MpegEncContext *s, | 492 void mpeg1_encode_mb(MpegEncContext *s, |
499 cbp = 0; | 502 cbp = 0; |
500 for(i=0;i<6;i++) { | 503 for(i=0;i<6;i++) { |
501 if (s->block_last_index[i] >= 0) | 504 if (s->block_last_index[i] >= 0) |
502 cbp |= 1 << (5 - i); | 505 cbp |= 1 << (5 - i); |
503 } | 506 } |
504 | 507 |
505 if (cbp == 0 && !first_mb && (mb_x != s->mb_width - 1 || (mb_y != s->mb_height - 1 && s->codec_id == CODEC_ID_MPEG1VIDEO)) && | 508 if (cbp == 0 && !first_mb && (mb_x != s->mb_width - 1 || (mb_y != s->mb_height - 1 && s->codec_id == CODEC_ID_MPEG1VIDEO)) && |
506 ((s->pict_type == P_TYPE && (motion_x | motion_y) == 0) || | 509 ((s->pict_type == P_TYPE && s->mv_type == MV_TYPE_16X16 && (motion_x | motion_y) == 0) || |
507 (s->pict_type == B_TYPE && s->mv_dir == s->last_mv_dir && (((s->mv_dir & MV_DIR_FORWARD) ? ((s->mv[0][0][0] - s->last_mv[0][0][0])|(s->mv[0][0][1] - s->last_mv[0][0][1])) : 0) | | 510 (s->pict_type == B_TYPE && s->mv_dir == s->last_mv_dir && (((s->mv_dir & MV_DIR_FORWARD) ? ((s->mv[0][0][0] - s->last_mv[0][0][0])|(s->mv[0][0][1] - s->last_mv[0][0][1])) : 0) | |
508 ((s->mv_dir & MV_DIR_BACKWARD) ? ((s->mv[1][0][0] - s->last_mv[1][0][0])|(s->mv[1][0][1] - s->last_mv[1][0][1])) : 0)) == 0))) { | 511 ((s->mv_dir & MV_DIR_BACKWARD) ? ((s->mv[1][0][0] - s->last_mv[1][0][0])|(s->mv[1][0][1] - s->last_mv[1][0][1])) : 0)) == 0))) { |
509 s->mb_skip_run++; | 512 s->mb_skip_run++; |
510 s->qscale -= s->dquant; | 513 s->qscale -= s->dquant; |
511 s->skip_count++; | 514 s->skip_count++; |
512 s->misc_bits++; | 515 s->misc_bits++; |
513 s->last_bits++; | 516 s->last_bits++; |
517 if(s->pict_type == P_TYPE){ | |
518 s->last_mv[0][1][0]= s->last_mv[0][0][0]= | |
519 s->last_mv[0][1][1]= s->last_mv[0][0][1]= 0; | |
520 } | |
514 } else { | 521 } else { |
515 if(first_mb){ | 522 if(first_mb){ |
516 assert(s->mb_skip_run == 0); | 523 assert(s->mb_skip_run == 0); |
517 encode_mb_skip_run(s, s->mb_x); | 524 encode_mb_skip_run(s, s->mb_x); |
518 }else{ | 525 }else{ |
519 encode_mb_skip_run(s, s->mb_skip_run); | 526 encode_mb_skip_run(s, s->mb_skip_run); |
520 } | 527 } |
521 | 528 |
522 if (s->pict_type == I_TYPE) { | 529 if (s->pict_type == I_TYPE) { |
523 if(s->dquant && cbp){ | 530 if(s->dquant && cbp){ |
524 put_mb_modes(s, 2, 1, 0); /* macroblock_type : macroblock_quant = 1 */ | 531 put_mb_modes(s, 2, 1, 0, 0); /* macroblock_type : macroblock_quant = 1 */ |
525 put_bits(&s->pb, 5, s->qscale); | 532 put_bits(&s->pb, 5, s->qscale); |
526 }else{ | 533 }else{ |
527 put_mb_modes(s, 1, 1, 0); /* macroblock_type : macroblock_quant = 0 */ | 534 put_mb_modes(s, 1, 1, 0, 0); /* macroblock_type : macroblock_quant = 0 */ |
528 s->qscale -= s->dquant; | 535 s->qscale -= s->dquant; |
529 } | 536 } |
530 s->misc_bits+= get_bits_diff(s); | 537 s->misc_bits+= get_bits_diff(s); |
531 s->i_count++; | 538 s->i_count++; |
532 } else if (s->mb_intra) { | 539 } else if (s->mb_intra) { |
533 if(s->dquant && cbp){ | 540 if(s->dquant && cbp){ |
534 put_mb_modes(s, 6, 0x01, 0); | 541 put_mb_modes(s, 6, 0x01, 0, 0); |
535 put_bits(&s->pb, 5, s->qscale); | 542 put_bits(&s->pb, 5, s->qscale); |
536 }else{ | 543 }else{ |
537 put_mb_modes(s, 5, 0x03, 0); | 544 put_mb_modes(s, 5, 0x03, 0, 0); |
538 s->qscale -= s->dquant; | 545 s->qscale -= s->dquant; |
539 } | 546 } |
540 s->misc_bits+= get_bits_diff(s); | 547 s->misc_bits+= get_bits_diff(s); |
541 s->i_count++; | 548 s->i_count++; |
542 s->last_mv[0][0][0] = | 549 memset(s->last_mv, 0, sizeof(s->last_mv)); |
543 s->last_mv[0][0][1] = 0; | |
544 } else if (s->pict_type == P_TYPE) { | 550 } else if (s->pict_type == P_TYPE) { |
551 if(s->mv_type == MV_TYPE_16X16){ | |
545 if (cbp != 0) { | 552 if (cbp != 0) { |
546 if (motion_x == 0 && motion_y == 0) { | 553 if ((motion_x|motion_y) == 0) { |
547 if(s->dquant){ | 554 if(s->dquant){ |
548 put_mb_modes(s, 5, 1, 0); /* macroblock_pattern & quant */ | 555 put_mb_modes(s, 5, 1, 0, 0); /* macroblock_pattern & quant */ |
549 put_bits(&s->pb, 5, s->qscale); | 556 put_bits(&s->pb, 5, s->qscale); |
550 }else{ | 557 }else{ |
551 put_mb_modes(s, 2, 1, 0); /* macroblock_pattern only */ | 558 put_mb_modes(s, 2, 1, 0, 0); /* macroblock_pattern only */ |
552 } | 559 } |
553 s->misc_bits+= get_bits_diff(s); | 560 s->misc_bits+= get_bits_diff(s); |
554 put_bits(&s->pb, mbPatTable[cbp - 1][1], mbPatTable[cbp - 1][0]); | |
555 } else { | 561 } else { |
556 if(s->dquant){ | 562 if(s->dquant){ |
557 put_mb_modes(s, 5, 2, 1); /* motion + cbp */ | 563 put_mb_modes(s, 5, 2, 1, 0); /* motion + cbp */ |
558 put_bits(&s->pb, 5, s->qscale); | 564 put_bits(&s->pb, 5, s->qscale); |
559 }else{ | 565 }else{ |
560 put_mb_modes(s, 1, 1, 1); /* motion + cbp */ | 566 put_mb_modes(s, 1, 1, 1, 0); /* motion + cbp */ |
561 } | 567 } |
562 s->misc_bits+= get_bits_diff(s); | 568 s->misc_bits+= get_bits_diff(s); |
563 mpeg1_encode_motion(s, motion_x - s->last_mv[0][0][0], s->f_code); // RAL: f_code parameter added | 569 mpeg1_encode_motion(s, motion_x - s->last_mv[0][0][0], s->f_code); // RAL: f_code parameter added |
564 mpeg1_encode_motion(s, motion_y - s->last_mv[0][0][1], s->f_code); // RAL: f_code parameter added | 570 mpeg1_encode_motion(s, motion_y - s->last_mv[0][0][1], s->f_code); // RAL: f_code parameter added |
565 s->mv_bits+= get_bits_diff(s); | 571 s->mv_bits+= get_bits_diff(s); |
566 put_bits(&s->pb, mbPatTable[cbp - 1][1], mbPatTable[cbp - 1][0]); | |
567 } | 572 } |
568 } else { | 573 } else { |
569 put_bits(&s->pb, 3, 1); /* motion only */ | 574 put_bits(&s->pb, 3, 1); /* motion only */ |
570 if (!s->frame_pred_frame_dct) | 575 if (!s->frame_pred_frame_dct) |
571 put_bits(&s->pb, 2, 2); /* motion_type: frame */ | 576 put_bits(&s->pb, 2, 2); /* motion_type: frame */ |
577 s->misc_bits+= get_bits_diff(s); | |
572 mpeg1_encode_motion(s, motion_x - s->last_mv[0][0][0], s->f_code); // RAL: f_code parameter added | 578 mpeg1_encode_motion(s, motion_x - s->last_mv[0][0][0], s->f_code); // RAL: f_code parameter added |
573 mpeg1_encode_motion(s, motion_y - s->last_mv[0][0][1], s->f_code); // RAL: f_code parameter added | 579 mpeg1_encode_motion(s, motion_y - s->last_mv[0][0][1], s->f_code); // RAL: f_code parameter added |
574 s->qscale -= s->dquant; | 580 s->qscale -= s->dquant; |
575 s->mv_bits+= get_bits_diff(s); | 581 s->mv_bits+= get_bits_diff(s); |
576 } | 582 } |
577 s->f_count++; | 583 s->last_mv[0][1][0]= s->last_mv[0][0][0]= motion_x; |
578 } else | 584 s->last_mv[0][1][1]= s->last_mv[0][0][1]= motion_y; |
579 { // RAL: All the following bloc added for B frames: | 585 }else{ |
580 if (cbp != 0) | 586 assert(!s->frame_pred_frame_dct && s->mv_type == MV_TYPE_FIELD); |
581 { // With coded bloc pattern | 587 |
582 if (s->mv_dir == (MV_DIR_FORWARD | MV_DIR_BACKWARD)) | 588 if (cbp) { |
583 { // Bi-directional motion | 589 if(s->dquant){ |
584 if (s->dquant) { | 590 put_mb_modes(s, 5, 2, 1, 1); /* motion + cbp */ |
585 put_mb_modes(s, 5, 2, 1); | 591 put_bits(&s->pb, 5, s->qscale); |
586 put_bits(&s->pb, 5, s->qscale); | 592 }else{ |
587 } else { | 593 put_mb_modes(s, 1, 1, 1, 1); /* motion + cbp */ |
588 put_mb_modes(s, 2, 3, 1); | |
589 } | |
590 s->misc_bits += get_bits_diff(s); | |
591 mpeg1_encode_motion(s, s->mv[0][0][0] - s->last_mv[0][0][0], s->f_code); | |
592 mpeg1_encode_motion(s, s->mv[0][0][1] - s->last_mv[0][0][1], s->f_code); | |
593 mpeg1_encode_motion(s, s->mv[1][0][0] - s->last_mv[1][0][0], s->b_code); | |
594 mpeg1_encode_motion(s, s->mv[1][0][1] - s->last_mv[1][0][1], s->b_code); | |
595 s->b_count++; | |
596 s->f_count++; | |
597 s->mv_bits += get_bits_diff(s); | |
598 put_bits(&s->pb, mbPatTable[cbp - 1][1], mbPatTable[cbp - 1][0]); | |
599 } | |
600 else if (s->mv_dir == MV_DIR_BACKWARD) | |
601 { // Backward motion | |
602 if (s->dquant) { | |
603 put_mb_modes(s, 6, 2, 1); | |
604 put_bits(&s->pb, 5, s->qscale); | |
605 } else { | |
606 put_mb_modes(s, 3, 3, 1); | |
607 } | |
608 s->misc_bits += get_bits_diff(s); | |
609 mpeg1_encode_motion(s, motion_x - s->last_mv[1][0][0], s->b_code); | |
610 mpeg1_encode_motion(s, motion_y - s->last_mv[1][0][1], s->b_code); | |
611 s->b_count++; | |
612 s->mv_bits += get_bits_diff(s); | |
613 put_bits(&s->pb, mbPatTable[cbp - 1][1], mbPatTable[cbp - 1][0]); | |
614 } | |
615 else if (s->mv_dir == MV_DIR_FORWARD) | |
616 { // Forward motion | |
617 if (s->dquant) { | |
618 put_mb_modes(s, 6, 3, 1); | |
619 put_bits(&s->pb, 5, s->qscale); | |
620 } else { | |
621 put_mb_modes(s, 4, 3, 1); | |
622 } | |
623 s->misc_bits += get_bits_diff(s); | |
624 mpeg1_encode_motion(s, motion_x - s->last_mv[0][0][0], s->f_code); | |
625 mpeg1_encode_motion(s, motion_y - s->last_mv[0][0][1], s->f_code); | |
626 s->f_count++; | |
627 s->mv_bits += get_bits_diff(s); | |
628 put_bits(&s->pb, mbPatTable[cbp - 1][1], mbPatTable[cbp - 1][0]); | |
629 } | |
630 } | 594 } |
631 else | 595 } else { |
632 { // No coded bloc pattern | 596 put_bits(&s->pb, 3, 1); /* motion only */ |
633 if (s->mv_dir == (MV_DIR_FORWARD | MV_DIR_BACKWARD)) | 597 put_bits(&s->pb, 2, 1); /* motion_type: field */ |
634 { // Bi-directional motion | |
635 put_bits(&s->pb, 2, 2); /* backward & forward motion */ | |
636 if (!s->frame_pred_frame_dct) | |
637 put_bits(&s->pb, 2, 2); /* motion_type: frame */ | |
638 mpeg1_encode_motion(s, s->mv[0][0][0] - s->last_mv[0][0][0], s->f_code); | |
639 mpeg1_encode_motion(s, s->mv[0][0][1] - s->last_mv[0][0][1], s->f_code); | |
640 mpeg1_encode_motion(s, s->mv[1][0][0] - s->last_mv[1][0][0], s->b_code); | |
641 mpeg1_encode_motion(s, s->mv[1][0][1] - s->last_mv[1][0][1], s->b_code); | |
642 s->b_count++; | |
643 s->f_count++; | |
644 } | |
645 else if (s->mv_dir == MV_DIR_BACKWARD) | |
646 { // Backward motion | |
647 put_bits(&s->pb, 3, 2); /* backward motion only */ | |
648 if (!s->frame_pred_frame_dct) | |
649 put_bits(&s->pb, 2, 2); /* motion_type: frame */ | |
650 mpeg1_encode_motion(s, motion_x - s->last_mv[1][0][0], s->b_code); | |
651 mpeg1_encode_motion(s, motion_y - s->last_mv[1][0][1], s->b_code); | |
652 s->b_count++; | |
653 } | |
654 else if (s->mv_dir == MV_DIR_FORWARD) | |
655 { // Forward motion | |
656 put_bits(&s->pb, 4, 2); /* forward motion only */ | |
657 if (!s->frame_pred_frame_dct) | |
658 put_bits(&s->pb, 2, 2); /* motion_type: frame */ | |
659 mpeg1_encode_motion(s, motion_x - s->last_mv[0][0][0], s->f_code); | |
660 mpeg1_encode_motion(s, motion_y - s->last_mv[0][0][1], s->f_code); | |
661 s->f_count++; | |
662 } | |
663 s->qscale -= s->dquant; | 598 s->qscale -= s->dquant; |
664 s->mv_bits += get_bits_diff(s); | 599 } |
600 s->misc_bits+= get_bits_diff(s); | |
601 for(i=0; i<2; i++){ | |
602 put_bits(&s->pb, 1, s->field_select[0][i]); | |
603 mpeg1_encode_motion(s, s->mv[0][i][0] - s->last_mv[0][i][0] , s->f_code); | |
604 mpeg1_encode_motion(s, s->mv[0][i][1] - (s->last_mv[0][i][1]>>1), s->f_code); | |
605 s->last_mv[0][i][0]= s->mv[0][i][0]; | |
606 s->last_mv[0][i][1]= 2*s->mv[0][i][1]; | |
607 } | |
608 s->mv_bits+= get_bits_diff(s); | |
609 } | |
610 if(cbp) | |
611 put_bits(&s->pb, mbPatTable[cbp - 1][1], mbPatTable[cbp - 1][0]); | |
612 s->f_count++; | |
613 } else{ | |
614 static const int mb_type_len[4]={0,3,4,2}; //bak,for,bi | |
615 | |
616 if(s->mv_type == MV_TYPE_16X16){ | |
617 if (cbp){ // With coded bloc pattern | |
618 if (s->dquant) { | |
619 if(s->mv_dir == MV_DIR_FORWARD) | |
620 put_mb_modes(s, 6, 3, 1, 0); | |
621 else | |
622 put_mb_modes(s, mb_type_len[s->mv_dir]+3, 2, 1, 0); | |
623 put_bits(&s->pb, 5, s->qscale); | |
624 } else { | |
625 put_mb_modes(s, mb_type_len[s->mv_dir], 3, 1, 0); | |
665 } | 626 } |
666 // End of bloc from RAL | 627 }else{ // No coded bloc pattern |
667 } | 628 put_bits(&s->pb, mb_type_len[s->mv_dir], 2); |
629 if (!s->frame_pred_frame_dct) | |
630 put_bits(&s->pb, 2, 2); /* motion_type: frame */ | |
631 s->qscale -= s->dquant; | |
632 } | |
633 s->misc_bits += get_bits_diff(s); | |
634 if (s->mv_dir&MV_DIR_FORWARD){ | |
635 mpeg1_encode_motion(s, s->mv[0][0][0] - s->last_mv[0][0][0], s->f_code); | |
636 mpeg1_encode_motion(s, s->mv[0][0][1] - s->last_mv[0][0][1], s->f_code); | |
637 s->last_mv[0][0][0]=s->last_mv[0][1][0]= s->mv[0][0][0]; | |
638 s->last_mv[0][0][1]=s->last_mv[0][1][1]= s->mv[0][0][1]; | |
639 s->f_count++; | |
640 } | |
641 if (s->mv_dir&MV_DIR_BACKWARD){ | |
642 mpeg1_encode_motion(s, s->mv[1][0][0] - s->last_mv[1][0][0], s->b_code); | |
643 mpeg1_encode_motion(s, s->mv[1][0][1] - s->last_mv[1][0][1], s->b_code); | |
644 s->last_mv[1][0][0]=s->last_mv[1][1][0]= s->mv[1][0][0]; | |
645 s->last_mv[1][0][1]=s->last_mv[1][1][1]= s->mv[1][0][1]; | |
646 s->b_count++; | |
647 } | |
648 }else{ | |
649 assert(s->mv_type == MV_TYPE_FIELD); | |
650 assert(!s->frame_pred_frame_dct); | |
651 if (cbp){ // With coded bloc pattern | |
652 if (s->dquant) { | |
653 if(s->mv_dir == MV_DIR_FORWARD) | |
654 put_mb_modes(s, 6, 3, 1, 1); | |
655 else | |
656 put_mb_modes(s, mb_type_len[s->mv_dir]+3, 2, 1, 1); | |
657 put_bits(&s->pb, 5, s->qscale); | |
658 } else { | |
659 put_mb_modes(s, mb_type_len[s->mv_dir], 3, 1, 1); | |
660 } | |
661 }else{ // No coded bloc pattern | |
662 put_bits(&s->pb, mb_type_len[s->mv_dir], 2); | |
663 put_bits(&s->pb, 2, 1); /* motion_type: field */ | |
664 s->qscale -= s->dquant; | |
665 } | |
666 s->misc_bits += get_bits_diff(s); | |
667 if (s->mv_dir&MV_DIR_FORWARD){ | |
668 for(i=0; i<2; i++){ | |
669 put_bits(&s->pb, 1, s->field_select[0][i]); | |
670 mpeg1_encode_motion(s, s->mv[0][i][0] - s->last_mv[0][i][0] , s->f_code); | |
671 mpeg1_encode_motion(s, s->mv[0][i][1] - (s->last_mv[0][i][1]>>1), s->f_code); | |
672 s->last_mv[0][i][0]= s->mv[0][i][0]; | |
673 s->last_mv[0][i][1]= 2*s->mv[0][i][1]; | |
674 } | |
675 s->f_count++; | |
676 } | |
677 if (s->mv_dir&MV_DIR_BACKWARD){ | |
678 for(i=0; i<2; i++){ | |
679 put_bits(&s->pb, 1, s->field_select[1][i]); | |
680 mpeg1_encode_motion(s, s->mv[1][i][0] - s->last_mv[1][i][0] , s->b_code); | |
681 mpeg1_encode_motion(s, s->mv[1][i][1] - (s->last_mv[1][i][1]>>1), s->b_code); | |
682 s->last_mv[1][i][0]= s->mv[1][i][0]; | |
683 s->last_mv[1][i][1]= 2*s->mv[1][i][1]; | |
684 } | |
685 s->b_count++; | |
686 } | |
687 } | |
688 s->mv_bits += get_bits_diff(s); | |
689 if(cbp) | |
690 put_bits(&s->pb, mbPatTable[cbp - 1][1], mbPatTable[cbp - 1][0]); | |
691 } | |
668 for(i=0;i<6;i++) { | 692 for(i=0;i<6;i++) { |
669 if (cbp & (1 << (5 - i))) { | 693 if (cbp & (1 << (5 - i))) { |
670 mpeg1_encode_block(s, block[i], i); | 694 mpeg1_encode_block(s, block[i], i); |
671 } | 695 } |
672 } | 696 } |
674 if(s->mb_intra) | 698 if(s->mb_intra) |
675 s->i_tex_bits+= get_bits_diff(s); | 699 s->i_tex_bits+= get_bits_diff(s); |
676 else | 700 else |
677 s->p_tex_bits+= get_bits_diff(s); | 701 s->p_tex_bits+= get_bits_diff(s); |
678 } | 702 } |
679 | |
680 // RAL: By this: | |
681 if (s->mv_dir & MV_DIR_FORWARD) | |
682 { | |
683 s->last_mv[0][0][0]= s->mv[0][0][0]; | |
684 s->last_mv[0][0][1]= s->mv[0][0][1]; | |
685 } | |
686 if (s->mv_dir & MV_DIR_BACKWARD) | |
687 { | |
688 s->last_mv[1][0][0]= s->mv[1][0][0]; | |
689 s->last_mv[1][0][1]= s->mv[1][0][1]; | |
690 } | |
691 } | 703 } |
692 | 704 |
693 // RAL: Parameter added: f_or_b_code | 705 // RAL: Parameter added: f_or_b_code |
694 static void mpeg1_encode_motion(MpegEncContext *s, int val, int f_or_b_code) | 706 static void mpeg1_encode_motion(MpegEncContext *s, int val, int f_or_b_code) |
695 { | 707 { |
1950 s->intra_vlc_format = get_bits1(&s->gb); | 1962 s->intra_vlc_format = get_bits1(&s->gb); |
1951 s->alternate_scan = get_bits1(&s->gb); | 1963 s->alternate_scan = get_bits1(&s->gb); |
1952 s->repeat_first_field = get_bits1(&s->gb); | 1964 s->repeat_first_field = get_bits1(&s->gb); |
1953 s->chroma_420_type = get_bits1(&s->gb); | 1965 s->chroma_420_type = get_bits1(&s->gb); |
1954 s->progressive_frame = get_bits1(&s->gb); | 1966 s->progressive_frame = get_bits1(&s->gb); |
1955 | 1967 |
1956 if(s->picture_structure == PICT_FRAME) | 1968 if(s->picture_structure == PICT_FRAME) |
1957 s->first_field=0; | 1969 s->first_field=0; |
1958 else{ | 1970 else{ |
1959 s->first_field ^= 1; | 1971 s->first_field ^= 1; |
1960 memset(s->mbskip_table, 0, s->mb_stride*s->mb_height); | 1972 memset(s->mbskip_table, 0, s->mb_stride*s->mb_height); |
1961 } | 1973 } |
1962 | 1974 |
1963 if(s->alternate_scan){ | 1975 if(s->alternate_scan){ |
1964 ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable , ff_alternate_vertical_scan); | 1976 ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable , ff_alternate_vertical_scan); |
1965 ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable , ff_alternate_vertical_scan); | 1977 ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable , ff_alternate_vertical_scan); |
1966 ff_init_scantable(s->dsp.idct_permutation, &s->intra_h_scantable, ff_alternate_vertical_scan); | |
1967 ff_init_scantable(s->dsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan); | |
1968 }else{ | 1978 }else{ |
1969 ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable , ff_zigzag_direct); | 1979 ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable , ff_zigzag_direct); |
1970 ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable , ff_zigzag_direct); | 1980 ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable , ff_zigzag_direct); |
1971 ff_init_scantable(s->dsp.idct_permutation, &s->intra_h_scantable, ff_alternate_horizontal_scan); | |
1972 ff_init_scantable(s->dsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan); | |
1973 } | 1981 } |
1974 | 1982 |
1975 /* composite display not parsed */ | 1983 /* composite display not parsed */ |
1976 dprintf("intra_dc_precision=%d\n", s->intra_dc_precision); | 1984 dprintf("intra_dc_precision=%d\n", s->intra_dc_precision); |
1977 dprintf("picture_structure=%d\n", s->picture_structure); | 1985 dprintf("picture_structure=%d\n", s->picture_structure); |
2101 init_get_bits(&s->gb, *buf, buf_size*8); | 2109 init_get_bits(&s->gb, *buf, buf_size*8); |
2102 | 2110 |
2103 s->qscale = get_qscale(s); | 2111 s->qscale = get_qscale(s); |
2104 if (s->first_slice && (s->first_field || s->picture_structure==PICT_FRAME)) { | 2112 if (s->first_slice && (s->first_field || s->picture_structure==PICT_FRAME)) { |
2105 if(s->avctx->debug&FF_DEBUG_PICT_INFO){ | 2113 if(s->avctx->debug&FF_DEBUG_PICT_INFO){ |
2106 av_log(s->avctx, AV_LOG_DEBUG, "qp:%d fc:%2d%2d%2d%2d %s %s %s %s dc:%d pstruct:%d fdct:%d cmv:%d qtype:%d ivlc:%d rff:%d %s\n", | 2114 av_log(s->avctx, AV_LOG_DEBUG, "qp:%d fc:%2d%2d%2d%2d %s %s %s %s %s dc:%d pstruct:%d fdct:%d cmv:%d qtype:%d ivlc:%d rff:%d %s\n", |
2107 s->qscale, s->mpeg_f_code[0][0],s->mpeg_f_code[0][1],s->mpeg_f_code[1][0],s->mpeg_f_code[1][1], | 2115 s->qscale, s->mpeg_f_code[0][0],s->mpeg_f_code[0][1],s->mpeg_f_code[1][0],s->mpeg_f_code[1][1], |
2108 s->pict_type == I_TYPE ? "I" : (s->pict_type == P_TYPE ? "P" : (s->pict_type == B_TYPE ? "B" : "S")), | 2116 s->pict_type == I_TYPE ? "I" : (s->pict_type == P_TYPE ? "P" : (s->pict_type == B_TYPE ? "B" : "S")), |
2109 s->progressive_sequence ? "pro" :"", s->alternate_scan ? "alt" :"", s->top_field_first ? "top" :"", | 2117 s->progressive_sequence ? "ps" :"", s->progressive_frame ? "pf" : "", s->alternate_scan ? "alt" :"", s->top_field_first ? "top" :"", |
2110 s->intra_dc_precision, s->picture_structure, s->frame_pred_frame_dct, s->concealment_motion_vectors, | 2118 s->intra_dc_precision, s->picture_structure, s->frame_pred_frame_dct, s->concealment_motion_vectors, |
2111 s->q_scale_type, s->intra_vlc_format, s->repeat_first_field, s->chroma_420_type ? "420" :""); | 2119 s->q_scale_type, s->intra_vlc_format, s->repeat_first_field, s->chroma_420_type ? "420" :""); |
2112 } | 2120 } |
2113 } | 2121 } |
2114 | 2122 |