Revision badaf88e libavcodec/msmpeg4.c

View differences:

libavcodec/msmpeg4.c
630 630
int msmpeg4_decode_picture_header(MpegEncContext * s)
631 631
{
632 632
    int code;
633
static int weirdAl=0;
633 634

  
634 635
    s->pict_type = get_bits(&s->gb, 2) + 1;
635 636
    if (s->pict_type != I_TYPE &&
......
642 643
        code = get_bits(&s->gb, 5); 
643 644
        /* 0x17: one slice, 0x18: three slices */
644 645
        /* XXX: implement it */
646
	//printf("%d %d %d\n", code, s->slice_height, s->first_slice_line);
645 647
        if (code < 0x17)
646 648
            return -1;
647 649
        s->slice_height = s->mb_height / (code - 0x16);
......
650 652

  
651 653
        s->dc_table_index = get_bits1(&s->gb);
652 654
        s->no_rounding = 1;
655
/*	printf(" %d %d %d %d     \n", 
656
		s->qscale,
657
		s->rl_chroma_table_index,
658
		s->rl_table_index, 
659
		s->dc_table_index);*/
653 660
    } else {
654 661
        s->use_skip_mb_code = get_bits1(&s->gb);
655 662
        
......
659 666
        s->dc_table_index = get_bits1(&s->gb);
660 667

  
661 668
        s->mv_table_index = get_bits1(&s->gb);
662
        s->no_rounding ^= 1;
669
/*	printf(" %d %d %d %d %d     \n", 
670
		s->use_skip_mb_code, 
671
		s->rl_table_index, 
672
		s->rl_chroma_table_index, 
673
		s->dc_table_index,
674
		s->mv_table_index);*/
675
  if(weirdAl)
676
	s->no_rounding = 0;
677
  else
678
	s->no_rounding ^= 1;
663 679
    }
664 680
#ifdef DEBUG
665 681
    printf("*****frame %d:\n", frame_count++);
......
785 801
    int dc_pred_dir;
786 802
    RLTable *rl;
787 803
    const UINT8 *scan_table;
804
    int qmul, qadd;
788 805

  
789 806
    if (s->mb_intra) {
807
        qmul=1;
808
        qadd=0;
809

  
790 810
	/* DC coef */
791 811
        set_stat(ST_DC);
792 812
        level = msmpeg4_decode_dc(s, n, &dc_pred_dir);
......
798 818
        } else {
799 819
            rl = &rl_table[3 + s->rl_chroma_table_index];
800 820
        }
821

  
801 822
        run_diff = 0;
802 823
	i = 1;
803 824
        if (!coded) {
......
813 834
        }
814 835
        set_stat(ST_INTRA_AC);
815 836
    } else {
837
        qmul = s->qscale << 1;
838
        qadd = (s->qscale - 1) | 1;
816 839
	i = 0;
817 840
        rl = &rl_table[3 + s->rl_table_index];
818 841
        run_diff = 1;
......
837 860
                    run = get_bits(&s->gb, 6);
838 861
                    level = get_bits(&s->gb, 8);
839 862
                    level = (level << 24) >> 24; /* sign extend */
863
                    if(level>0) level= level * qmul + qadd;
864
                    else        level= level * qmul - qadd;
840 865
                } else {
841 866
                    /* second escape */
842 867
                    code = get_vlc(&s->gb, &rl->vlc);
843 868
                    if (code < 0 || code >= rl->n)
844 869
                        return -1;
845 870
                    run = rl->table_run[code];
846
                    level = rl->table_level[code];
871
                    level = rl->table_level[code] * qmul + qadd;
847 872
                    last = code >= rl->last;
848 873
                    run += rl->max_run[last][level] + run_diff;
849 874
                    if (get_bits1(&s->gb))
......
858 883
                level = rl->table_level[code];
859 884
                last = code >= rl->last;
860 885
                level += rl->max_level[last][run];
886
                level= level * qmul + qadd;
861 887
                if (get_bits1(&s->gb))
862 888
                    level = -level;
863 889
            }
864 890
        } else {
865 891
            run = rl->table_run[code];
866
            level = rl->table_level[code];
892
            level = rl->table_level[code] * qmul + qadd;
867 893
            last = code >= rl->last;
868 894
            if (get_bits1(&s->gb))
869 895
                level = -level;

Also available in: Unified diff