Revision 174489bd

View differences:

libavcodec/motion_est.c
579 579
    int mx, my, mx1, my1, d, xx, yy, dminh;
580 580
    UINT8 *pix, *ptr;
581 581

  
582
    
583 582
    mx = *mx_ptr;
584 583
    my = *my_ptr;
585 584
    ptr = s->last_picture[0] + (my * s->linesize) + mx;
......
678 677
    case ME_PHODS:
679 678
	dmin = phods_motion_search(s, &mx, &my, range / 2, xmin, ymin, xmax, ymax);
680 679
        break;
681
    case ME_X1: // just reserving some space for experiments ...
680
    case ME_X1:
682 681
    case ME_EPZS:
683
        rel_xmin= xmin - s->mb_x*16;
684
        rel_xmax= xmax - s->mb_x*16;
685
        rel_ymin= ymin - s->mb_y*16;
686
        rel_ymax= ymax - s->mb_y*16;
687
        if(s->out_format == FMT_H263){
682
       {
688 683
            static const int off[4]= {2, 1, 1, -1};
689 684
            const int mot_stride = s->mb_width*2 + 2;
690 685
            const int mot_xy = (s->mb_y*2 + 1)*mot_stride + s->mb_x*2 + 1;
691
         
686

  
687
            rel_xmin= xmin - s->mb_x*16;
688
            rel_xmax= xmax - s->mb_x*16;
689
            rel_ymin= ymin - s->mb_y*16;
690
            rel_ymax= ymax - s->mb_y*16;
691

  
692 692
            P[0][0] = s->motion_val[mot_xy    ][0];
693 693
            P[0][1] = s->motion_val[mot_xy    ][1];
694 694
            P[1][0] = s->motion_val[mot_xy - 1][0];
......
697 697

  
698 698
            /* special case for first line */
699 699
            if ((s->mb_y == 0 || s->first_slice_line || s->first_gob_line)) {
700
                pred_x = P[1][0];
701
                pred_y = P[1][1];
700
                P[4][0] = P[1][0];
701
                P[4][1] = P[1][1];
702 702
            } else {
703 703
                P[2][0] = s->motion_val[mot_xy - mot_stride             ][0];
704 704
                P[2][1] = s->motion_val[mot_xy - mot_stride             ][1];
......
708 708
                if(P[3][0] < (rel_xmin<<shift)) P[3][0]= (rel_xmin<<shift);
709 709
                if(P[3][1] > (rel_ymax<<shift)) P[3][1]= (rel_ymax<<shift);
710 710
        
711
                P[4][0]= pred_x = mid_pred(P[1][0], P[2][0], P[3][0]);
712
                P[4][1]= pred_y = mid_pred(P[1][1], P[2][1], P[3][1]);
713
            }
714
        }else {
715
            const int xy= s->mb_y*s->mb_width + s->mb_x;
716
            pred_x= s->last_mv[0][0][0];
717
            pred_y= s->last_mv[0][0][1];
718

  
719
            P[0][0]= s->mv_table[0][xy  ];
720
            P[0][1]= s->mv_table[1][xy  ];
721
            if(s->mb_x == 0){
722
                P[1][0]= 0;
723
                P[1][1]= 0;
724
            }else{
725
                P[1][0]= s->mv_table[0][xy-1];
726
                P[1][1]= s->mv_table[1][xy-1];
727
                if(P[1][0] > (rel_xmax<<shift)) P[1][0]= (rel_xmax<<shift);
728
            }
729
    
730
            if (!(s->mb_y == 0 || s->first_slice_line || s->first_gob_line)) {
731
                P[2][0] = s->mv_table[0][xy - s->mb_width];
732
                P[2][1] = s->mv_table[1][xy - s->mb_width];
733
                P[3][0] = s->mv_table[0][xy - s->mb_width+1];
734
                P[3][1] = s->mv_table[1][xy - s->mb_width+1];
735
                if(P[2][1] > (rel_ymax<<shift)) P[2][1]= (rel_ymax<<shift);
736
                if(P[3][0] > (rel_xmax<<shift)) P[3][0]= (rel_xmax<<shift);
737
                if(P[3][0] < (rel_xmin<<shift)) P[3][0]= (rel_xmin<<shift);
738
                if(P[3][1] > (rel_ymax<<shift)) P[3][1]= (rel_ymax<<shift);
739
        
740 711
                P[4][0]= mid_pred(P[1][0], P[2][0], P[3][0]);
741 712
                P[4][1]= mid_pred(P[1][1], P[2][1], P[3][1]);
742 713
            }
714
            if(s->out_format == FMT_H263){
715
                pred_x = P[4][0];
716
                pred_y = P[4][1];
717
            }else { /* mpeg1 at least */
718
                pred_x= P[1][0];
719
                pred_y= P[1][1];
720
            }
743 721
        }
744 722
        dmin = epzs_motion_search(s, &mx, &my, P, pred_x, pred_y, rel_xmin, rel_ymin, rel_xmax, rel_ymax);
745 723
 
libavcodec/mpegvideo.c
174 174
        }
175 175
    }
176 176
    
177
    if (s->out_format == FMT_H263) {
177
    if (s->out_format == FMT_H263 || s->encoding) {
178 178
        int size;
179 179
        /* MV prediction */
180 180
        size = (2 * s->mb_width + 2) * (2 * s->mb_height + 2);
......
295 295
    s->qblur= avctx->qblur;
296 296
    s->avctx = avctx;
297 297
    s->aspect_ratio_info= avctx->aspect_ratio_info;
298
    s->hq= (avctx->flags & CODEC_FLAG_HQ);
298 299
    
299 300
    if (s->gop_size <= 1) {
300 301
        s->intra_only = 1;
......
506 507

  
507 508
    if (!s->intra_only) {
508 509
        /* first picture of GOP is intra */
509
        if (s->picture_in_gop_number >= s->gop_size){
510
        if (s->picture_in_gop_number % s->gop_size==0){
510 511
            s->picture_in_gop_number=0;
511 512
            s->pict_type = I_TYPE;
512 513
        }else
......
1097 1098
    for(mb_y=0; mb_y < s->mb_height; mb_y++) {
1098 1099
        for(mb_x=0; mb_x < s->mb_width; mb_x++) {
1099 1100
            int xy= mb_y * s->mb_width + mb_x;
1101
            const int mot_stride = s->mb_width*2 + 2;
1102
            int mot_xy = (mb_y*2 + 1)*mot_stride + mb_x*2 + 1;
1100 1103
            s->mb_x = mb_x;
1101 1104
            s->mb_y = mb_y;
1102 1105

  
......
1114 1117
            s->mb_type[xy] = s->mb_intra;
1115 1118
            s->mv_table[0][xy] = motion_x;
1116 1119
            s->mv_table[1][xy] = motion_y;
1120

  
1121
            s->motion_val[mot_xy  ][0]= motion_x;
1122
            s->motion_val[mot_xy  ][1]= motion_y;
1123
            s->motion_val[mot_xy+1][0]= motion_x;
1124
            s->motion_val[mot_xy+1][1]= motion_y;
1125
            mot_xy += mot_stride;
1126
            s->motion_val[mot_xy  ][0]= motion_x;
1127
            s->motion_val[mot_xy  ][1]= motion_y;
1128
            s->motion_val[mot_xy+1][0]= motion_x;
1129
            s->motion_val[mot_xy+1][1]= motion_y;
1117 1130
        }
1118 1131
    }
1119 1132
    emms_c();
libavcodec/mpegvideo.h
65 65
    int qmax;         /* max qscale */
66 66
    int max_qdiff;    /* max qscale difference between frames */
67 67
    int encoding;     /* true if we are encoding (vs decoding) */
68
    int hq;           /* set if CODEC_FLAG_HQ is used in AVCodecContext.flags */
68 69
    /* the following fields are managed internally by the encoder */
69 70

  
70 71
    /* bit output */

Also available in: Unified diff