Revision 14268254

View differences:

libavcodec/vp3.c
48 48
typedef struct Vp3Fragment {
49 49
    int16_t dc;
50 50
    uint8_t coding_method;
51
    int8_t motion_x;
52
    int8_t motion_y;
53 51
    uint8_t qpi;
54 52
} Vp3Fragment;
55 53

  
......
166 164
    int fragment_start[3];
167 165
    int data_offset[3];
168 166

  
167
    int8_t (*motion_val[2])[2];
168

  
169 169
    ScanTable scantable;
170 170

  
171 171
    /* tables */
......
624 624
    int prior_last_motion_y = 0;
625 625
    int current_macroblock;
626 626
    int current_fragment;
627
    Vp3Fragment *frag;
627
    int frag;
628 628

  
629 629
    if (s->keyframe)
630 630
        return 0;
......
731 731
                current_fragment =
732 732
                    BLOCK_Y*s->fragment_width[0] + BLOCK_X;
733 733
                if (s->macroblock_coding[current_macroblock] == MODE_INTER_FOURMV) {
734
                    s->all_fragments[current_fragment].motion_x = motion_x[k];
735
                    s->all_fragments[current_fragment].motion_y = motion_y[k];
734
                    s->motion_val[0][current_fragment][0] = motion_x[k];
735
                    s->motion_val[0][current_fragment][1] = motion_y[k];
736 736
                } else {
737
                    s->all_fragments[current_fragment].motion_x = motion_x[0];
738
                    s->all_fragments[current_fragment].motion_y = motion_y[0];
737
                    s->motion_val[0][current_fragment][0] = motion_x[0];
738
                    s->motion_val[0][current_fragment][1] = motion_y[0];
739 739
                }
740 740
            }
741 741

  
742
#define SET_CHROMA_MV(mx, my) \
743
    frag[s->fragment_start[1]].motion_x = mx; \
744
    frag[s->fragment_start[1]].motion_y = my; \
745
    frag[s->fragment_start[2]].motion_x = mx; \
746
    frag[s->fragment_start[2]].motion_y = my
747

  
748 742
            if (s->chroma_y_shift) {
749 743
                if (s->macroblock_coding[current_macroblock] == MODE_INTER_FOURMV) {
750 744
                    motion_x[0] = RSHIFT(motion_x[0] + motion_x[1] + motion_x[2] + motion_x[3], 2);
......
752 746
                }
753 747
                motion_x[0] = (motion_x[0]>>1) | (motion_x[0]&1);
754 748
                motion_y[0] = (motion_y[0]>>1) | (motion_y[0]&1);
755
                frag = s->all_fragments + mb_y*s->fragment_width[1] + mb_x;
756
                SET_CHROMA_MV(motion_x[0], motion_y[0]);
749
                frag = mb_y*s->fragment_width[1] + mb_x;
750
                s->motion_val[1][frag][0] = motion_x[0];
751
                s->motion_val[1][frag][1] = motion_y[0];
757 752
            } else if (s->chroma_x_shift) {
758 753
                if (s->macroblock_coding[current_macroblock] == MODE_INTER_FOURMV) {
759 754
                    motion_x[0] = RSHIFT(motion_x[0] + motion_x[1], 1);
......
767 762
                motion_x[0] = (motion_x[0]>>1) | (motion_x[0]&1);
768 763
                motion_x[1] = (motion_x[1]>>1) | (motion_x[1]&1);
769 764

  
770
                frag = s->all_fragments + 2*mb_y*s->fragment_width[1] + mb_x;
765
                frag = 2*mb_y*s->fragment_width[1] + mb_x;
771 766
                for (k = 0; k < 2; k++) {
772
                    SET_CHROMA_MV(motion_x[k], motion_y[k]);
767
                    s->motion_val[1][frag][0] = motion_x[k];
768
                    s->motion_val[1][frag][1] = motion_y[k];
773 769
                    frag += s->fragment_width[1];
774 770
                }
775 771
            } else {
776 772
                for (k = 0; k < 4; k++) {
777
                    frag = s->all_fragments + BLOCK_Y*s->fragment_width[1] + BLOCK_X;
773
                    frag = BLOCK_Y*s->fragment_width[1] + BLOCK_X;
778 774
                    if (s->macroblock_coding[current_macroblock] == MODE_INTER_FOURMV) {
779
                        SET_CHROMA_MV(motion_x[k], motion_y[k]);
775
                        s->motion_val[1][frag][0] = motion_x[k];
776
                        s->motion_val[1][frag][1] = motion_y[k];
780 777
                    } else {
781
                        SET_CHROMA_MV(motion_x[0], motion_y[0]);
778
                        s->motion_val[1][frag][0] = motion_x[0];
779
                        s->motion_val[1][frag][1] = motion_y[0];
782 780
                    }
783 781
                }
784 782
            }
......
1354 1352
        int stride            = s->current_frame.linesize[plane];
1355 1353
        int plane_width       = s->width  >> (plane && s->chroma_x_shift);
1356 1354
        int plane_height      = s->height >> (plane && s->chroma_y_shift);
1355
        int8_t (*motion_val)[2] = s->motion_val[!!plane];
1357 1356

  
1358 1357
        int sb_x, sb_y        = slice << (!plane && s->chroma_y_shift);
1359 1358
        int slice_height      = sb_y + 1 + (!plane && s->chroma_y_shift);
......
1408 1407
                    if ((s->all_fragments[i].coding_method > MODE_INTRA) &&
1409 1408
                        (s->all_fragments[i].coding_method != MODE_USING_GOLDEN)) {
1410 1409
                        int src_x, src_y;
1411
                        motion_x = s->all_fragments[i].motion_x;
1412
                        motion_y = s->all_fragments[i].motion_y;
1410
                        motion_x = motion_val[y*fragment_width + x][0];
1411
                        motion_y = motion_val[y*fragment_width + x][1];
1413 1412

  
1414 1413
                        src_x= (motion_x>>1) + 8*x;
1415 1414
                        src_y= (motion_y>>1) + 8*y;
......
1568 1567
    s->all_fragments = av_malloc(s->fragment_count * sizeof(Vp3Fragment));
1569 1568
    s->coded_fragment_list[0] = av_malloc(s->fragment_count * sizeof(int));
1570 1569
    s->dct_tokens_base = av_malloc(64*s->fragment_count * sizeof(*s->dct_tokens_base));
1570
    s->motion_val[0] = av_malloc(y_fragment_count * sizeof(*s->motion_val[0]));
1571
    s->motion_val[1] = av_malloc(c_fragment_count * sizeof(*s->motion_val[1]));
1572

  
1571 1573
    if (!s->superblock_coding || !s->all_fragments || !s->dct_tokens_base ||
1572
        !s->coded_fragment_list[0]) {
1574
        !s->coded_fragment_list[0] || !s->motion_val[0] || !s->motion_val[1]) {
1573 1575
        vp3_decode_end(avctx);
1574 1576
        return -1;
1575 1577
    }
......
1874 1876
    av_free(s->dct_tokens_base);
1875 1877
    av_free(s->superblock_fragments);
1876 1878
    av_free(s->macroblock_coding);
1879
    av_free(s->motion_val[0]);
1880
    av_free(s->motion_val[1]);
1877 1881

  
1878 1882
    for (i = 0; i < 16; i++) {
1879 1883
        free_vlc(&s->dc_vlc[i]);

Also available in: Unified diff