Revision c47d3835

View differences:

libavcodec/vc1.h
236 236
    //@}
237 237
    int ttfrm;            ///< Transform type info present at frame level
238 238
    uint8_t ttmbf;        ///< Transform type flag
239
    uint8_t ttblk4x4;     ///< Value of ttblk which indicates a 4x4 transform
239
    int *ttblk_base, *ttblk; ///< Transform type at the block level
240 240
    int codingset;        ///< index of current table set from 11.8 to use for luma block decoding
241 241
    int codingset2;       ///< index of current table set from 11.8 to use for chroma block decoding
242 242
    int pqindex;          ///< raw pqindex used in coding set selection
......
311 311
    int x8_type;
312 312

  
313 313
    uint32_t *cbp_base, *cbp;
314
    uint8_t *is_intra_base, *is_intra;
315
    int16_t (*luma_mv_base)[2], (*luma_mv)[2];
314 316
    uint8_t bfraction_lut_index;///< Index for BFRACTION value (see Table 40, reproduced into ff_vc1_bfraction_lut[])
315 317
    uint8_t broken_link;        ///< Broken link flag (BROKEN_LINK syntax element)
316 318
    uint8_t closed_entry;       ///< Closed entry point flag (CLOSED_ENTRY syntax element)
libavcodec/vc1dec.c
209 209
    }
210 210
    uvmx = (mx + ((mx & 3) == 3)) >> 1;
211 211
    uvmy = (my + ((my & 3) == 3)) >> 1;
212
    v->luma_mv[s->mb_x][0] = uvmx;
213
    v->luma_mv[s->mb_x][1] = uvmy;
212 214
    if(v->fastuvmc) {
213 215
        uvmx = uvmx + ((uvmx<0)?(uvmx&1):-(uvmx&1));
214 216
        uvmy = uvmy + ((uvmy<0)?(uvmy&1):-(uvmy&1));
......
477 479
    } else {
478 480
        s->current_picture.motion_val[1][s->block_index[0]][0] = 0;
479 481
        s->current_picture.motion_val[1][s->block_index[0]][1] = 0;
482
        v->luma_mv[s->mb_x][0] = v->luma_mv[s->mb_x][1] = 0;
480 483
        return; //no need to do MC for inter blocks
481 484
    }
482 485

  
......
484 487
    s->current_picture.motion_val[1][s->block_index[0]][1] = ty;
485 488
    uvmx = (tx + ((tx&3) == 3)) >> 1;
486 489
    uvmy = (ty + ((ty&3) == 3)) >> 1;
490
    v->luma_mv[s->mb_x][0] = uvmx;
491
    v->luma_mv[s->mb_x][1] = uvmy;
487 492
    if(v->fastuvmc) {
488 493
        uvmx = uvmx + ((uvmx<0)?(uvmx&1):-(uvmx&1));
489 494
        uvmy = uvmy + ((uvmy<0)?(uvmy&1):-(uvmy&1));
......
652 657

  
653 658
/** Predict and set motion vector
654 659
 */
655
static inline void vc1_pred_mv(MpegEncContext *s, int n, int dmv_x, int dmv_y, int mv1, int r_x, int r_y, uint8_t* is_intra)
660
static inline void vc1_pred_mv(VC1Context *v, int n, int dmv_x, int dmv_y, int mv1, int r_x, int r_y, uint8_t* is_intra)
656 661
{
662
    MpegEncContext *s = &v->s;
657 663
    int xy, wrap, off = 0;
658 664
    int16_t *A, *B, *C;
659 665
    int px, py;
......
678 684
            s->current_picture.motion_val[0][xy + wrap][1] = 0;
679 685
            s->current_picture.motion_val[0][xy + wrap + 1][0] = 0;
680 686
            s->current_picture.motion_val[0][xy + wrap + 1][1] = 0;
687
            v->luma_mv[s->mb_x][0] = v->luma_mv[s->mb_x][1] = 0;
681 688
            s->current_picture.motion_val[1][xy + 1][0] = 0;
682 689
            s->current_picture.motion_val[1][xy + 1][1] = 0;
683 690
            s->current_picture.motion_val[1][xy + wrap][0] = 0;
......
1953 1960
/** Decode P block
1954 1961
 */
1955 1962
static int vc1_decode_p_block(VC1Context *v, DCTELEM block[64], int n, int mquant, int ttmb, int first_block,
1956
                              uint8_t *dst, int linesize, int skip_block, int apply_filter, int cbp_top, int cbp_left)
1963
                              uint8_t *dst, int linesize, int skip_block, int *ttmb_out)
1957 1964
{
1958 1965
    MpegEncContext *s = &v->s;
1959 1966
    GetBitContext *gb = &s->gb;
......
2011 2018
            else{
2012 2019
                v->vc1dsp.vc1_inv_trans_8x8_add(dst, linesize, block);
2013 2020
            }
2014
            if(apply_filter && cbp_top  & 0xC)
2015
                v->vc1dsp.vc1_v_loop_filter8(dst, linesize, v->pq);
2016
            if(apply_filter && cbp_left & 0xA)
2017
                v->vc1dsp.vc1_h_loop_filter8(dst, linesize, v->pq);
2018 2021
        }
2019 2022
        break;
2020 2023
    case TT_4X4:
......
2038 2041
                    v->vc1dsp.vc1_inv_trans_4x4_dc(dst + (j&1)*4 + (j&2)*2*linesize, linesize, block + off);
2039 2042
                else
2040 2043
                    v->vc1dsp.vc1_inv_trans_4x4(dst + (j&1)*4 + (j&2)*2*linesize, linesize, block + off);
2041
                if(apply_filter && (j&2 ? pat & (1<<(j-2)) : (cbp_top & (1 << (j + 2)))))
2042
                    v->vc1dsp.vc1_v_loop_filter4(dst + (j&1)*4 + (j&2)*2*linesize, linesize, v->pq);
2043
                if(apply_filter && (j&1 ? pat & (1<<(j-1)) : (cbp_left & (1 << (j + 1)))))
2044
                    v->vc1dsp.vc1_h_loop_filter4(dst + (j&1)*4 + (j&2)*2*linesize, linesize, v->pq);
2045 2044
            }
2046 2045
        }
2047 2046
        break;
......
2066 2065
                    v->vc1dsp.vc1_inv_trans_8x4_dc(dst + j*4*linesize, linesize, block + off);
2067 2066
                else
2068 2067
                    v->vc1dsp.vc1_inv_trans_8x4(dst + j*4*linesize, linesize, block + off);
2069
                if(apply_filter && j ? pat & 0x3 : (cbp_top & 0xC))
2070
                    v->vc1dsp.vc1_v_loop_filter8(dst + j*4*linesize, linesize, v->pq);
2071
                if(apply_filter && cbp_left & (2 << j))
2072
                    v->vc1dsp.vc1_h_loop_filter4(dst + j*4*linesize, linesize, v->pq);
2073 2068
            }
2074 2069
        }
2075 2070
        break;
......
2094 2089
                    v->vc1dsp.vc1_inv_trans_4x8_dc(dst + j*4, linesize, block + off);
2095 2090
                else
2096 2091
                    v->vc1dsp.vc1_inv_trans_4x8(dst + j*4, linesize, block + off);
2097
                if(apply_filter && cbp_top & (2 << j))
2098
                    v->vc1dsp.vc1_v_loop_filter4(dst + j*4, linesize, v->pq);
2099
                if(apply_filter && j ? pat & 0x5 : (cbp_left & 0xA))
2100
                    v->vc1dsp.vc1_h_loop_filter8(dst + j*4, linesize, v->pq);
2101 2092
            }
2102 2093
        }
2103 2094
        break;
2104 2095
    }
2096
    if (ttmb_out)
2097
        *ttmb_out |= ttblk << (n * 4);
2105 2098
    return pat;
2106 2099
}
2107 2100

  
......
2110 2103
static const int size_table  [6] = { 0, 2, 3, 4,  5,  8 };
2111 2104
static const int offset_table[6] = { 0, 1, 3, 7, 15, 31 };
2112 2105

  
2106
static av_always_inline void vc1_apply_p_v_loop_filter(VC1Context *v, int block_num)
2107
{
2108
    MpegEncContext *s = &v->s;
2109
    int mb_cbp         = v->cbp[s->mb_x - s->mb_stride],
2110
        block_cbp      = mb_cbp      >> (block_num * 4), bottom_cbp,
2111
        mb_is_intra    = v->is_intra[s->mb_x - s->mb_stride],
2112
        block_is_intra = mb_is_intra >> (block_num * 4), bottom_is_intra;
2113
    int idx, linesize = block_num > 3 ? s->uvlinesize : s->linesize, ttblk;
2114
    uint8_t *dst;
2115

  
2116
    if(block_num > 3) {
2117
        dst      = s->dest[block_num - 3];
2118
    } else {
2119
        dst      = s->dest[0] + (block_num & 1) * 8 + ((block_num & 2) * 4 - 8) * linesize;
2120
    }
2121
    if (s->mb_y != s->mb_height || block_num < 2) {
2122
        int16_t (*mv)[2];
2123
        int mv_stride;
2124

  
2125
        if(block_num > 3) {
2126
            bottom_cbp      = v->cbp[s->mb_x]      >> (block_num * 4);
2127
            bottom_is_intra = v->is_intra[s->mb_x] >> (block_num * 4);
2128
            mv              = &v->luma_mv[s->mb_x - s->mb_stride];
2129
            mv_stride       = s->mb_stride;
2130
        } else {
2131
            bottom_cbp      = (block_num < 2) ? (mb_cbp               >> ((block_num + 2) * 4)) :
2132
                                                (v->cbp[s->mb_x]      >> ((block_num - 2) * 4));
2133
            bottom_is_intra = (block_num < 2) ? (mb_is_intra          >> ((block_num + 2) * 4)) :
2134
                                                (v->is_intra[s->mb_x] >> ((block_num - 2) * 4));
2135
            mv_stride       = s->b8_stride;
2136
            mv              = &s->current_picture.motion_val[0][s->block_index[block_num] - 2 * mv_stride];
2137
        }
2138

  
2139
        if (bottom_is_intra & 1 || block_is_intra & 1 ||
2140
            mv[0][0] != mv[mv_stride][0] || mv[0][1] != mv[mv_stride][1]) {
2141
            v->vc1dsp.vc1_v_loop_filter8(dst, linesize, v->pq);
2142
        } else {
2143
            idx = ((bottom_cbp >> 2) | block_cbp) & 3;
2144
            if(idx == 3) {
2145
                v->vc1dsp.vc1_v_loop_filter8(dst, linesize, v->pq);
2146
            } else if (idx) {
2147
                if (idx == 1)
2148
                    v->vc1dsp.vc1_v_loop_filter4(dst + 4, linesize, v->pq);
2149
                else
2150
                    v->vc1dsp.vc1_v_loop_filter4(dst,     linesize, v->pq);
2151
            }
2152
        }
2153
    }
2154

  
2155
    dst -= 4 * linesize;
2156
    ttblk = (v->ttblk[s->mb_x - s->mb_stride] >> (block_num * 4)) & 0xf;
2157
    if (ttblk == TT_4X4 || ttblk == TT_8X4) {
2158
        idx = (block_cbp | (block_cbp >> 2)) & 3;
2159
        if (idx == 3) {
2160
            v->vc1dsp.vc1_v_loop_filter8(dst, linesize, v->pq);
2161
        } else if (idx) {
2162
            if (idx == 1)
2163
                v->vc1dsp.vc1_v_loop_filter4(dst + 4, linesize, v->pq);
2164
            else
2165
                v->vc1dsp.vc1_v_loop_filter4(dst,     linesize, v->pq);
2166
        }
2167
    }
2168
}
2169

  
2170
static av_always_inline void vc1_apply_p_h_loop_filter(VC1Context *v, int block_num)
2171
{
2172
    MpegEncContext *s = &v->s;
2173
    int mb_cbp         = v->cbp[s->mb_x - 1 - s->mb_stride],
2174
        block_cbp      = mb_cbp      >> (block_num * 4), right_cbp,
2175
        mb_is_intra    = v->is_intra[s->mb_x - 1 - s->mb_stride],
2176
        block_is_intra = mb_is_intra >> (block_num * 4), right_is_intra;
2177
    int idx, linesize = block_num > 3 ? s->uvlinesize : s->linesize, ttblk;
2178
    uint8_t *dst;
2179

  
2180
    if (block_num > 3) {
2181
        dst = s->dest[block_num - 3] - 8 * linesize;
2182
    } else {
2183
        dst = s->dest[0] + (block_num & 1) * 8 + ((block_num & 2) * 4 - 16) * linesize - 8;
2184
    }
2185

  
2186
    if (s->mb_x != s->mb_width || !(block_num & 5)) {
2187
        int16_t (*mv)[2];
2188

  
2189
        if(block_num > 3) {
2190
            right_cbp      = v->cbp[s->mb_x - s->mb_stride] >> (block_num * 4);
2191
            right_is_intra = v->is_intra[s->mb_x - s->mb_stride] >> (block_num * 4);
2192
            mv             = &v->luma_mv[s->mb_x - s->mb_stride - 1];
2193
        }else{
2194
            right_cbp      = (block_num & 1) ? (v->cbp[s->mb_x - s->mb_stride]      >> ((block_num - 1) * 4)) :
2195
                                               (mb_cbp                              >> ((block_num + 1) * 4));
2196
            right_is_intra = (block_num & 1) ? (v->is_intra[s->mb_x - s->mb_stride] >> ((block_num - 1) * 4)) :
2197
                                               (mb_is_intra                         >> ((block_num + 1) * 4));
2198
            mv             = &s->current_picture.motion_val[0][s->block_index[block_num] - s->b8_stride * 2 - 2];
2199
        }
2200
        if (block_is_intra & 1 || right_is_intra & 1 || mv[0][0] != mv[1][0] || mv[0][1] != mv[1][1]) {
2201
            v->vc1dsp.vc1_h_loop_filter8(dst, linesize, v->pq);
2202
        } else {
2203
            idx = ((right_cbp >> 1) | block_cbp) & 5; // FIXME check
2204
            if (idx == 5) {
2205
                v->vc1dsp.vc1_h_loop_filter8(dst, linesize, v->pq);
2206
            } else if (idx) {
2207
                if (idx == 1)
2208
                    v->vc1dsp.vc1_h_loop_filter4(dst+4*linesize, linesize, v->pq);
2209
                else
2210
                    v->vc1dsp.vc1_h_loop_filter4(dst,            linesize, v->pq);
2211
            }
2212
        }
2213
    }
2214

  
2215
    dst -= 4;
2216
    ttblk = (v->ttblk[s->mb_x - s->mb_stride - 1] >> (block_num * 4)) & 0xf;
2217
    if (ttblk == TT_4X4 || ttblk == TT_4X8) {
2218
        idx = (block_cbp | (block_cbp >> 1)) & 5;
2219
        if (idx == 5) {
2220
            v->vc1dsp.vc1_h_loop_filter8(dst, linesize, v->pq);
2221
        } else if (idx) {
2222
            if (idx == 1)
2223
                v->vc1dsp.vc1_h_loop_filter4(dst + linesize*4, linesize, v->pq);
2224
            else
2225
                v->vc1dsp.vc1_h_loop_filter4(dst,              linesize, v->pq);
2226
        }
2227
    }
2228
}
2229

  
2230
static void vc1_apply_p_loop_filter(VC1Context *v)
2231
{
2232
    MpegEncContext *s = &v->s;
2233
    int i;
2234

  
2235
    for (i = 0; i < 6; i++) {
2236
        vc1_apply_p_v_loop_filter(v, i);
2237
    }
2238

  
2239
    /* V always preceedes H, therefore we run H one MB before V;
2240
     * at the end of a row, we catch up to complete the row */
2241
    if (s->mb_x) {
2242
        for (i = 0; i < 6; i++) {
2243
            vc1_apply_p_h_loop_filter(v, i);
2244
        }
2245
        if (s->mb_x == s->mb_width - 1) {
2246
            s->mb_x++;
2247
            ff_update_block_index(s);
2248
            for (i = 0; i < 6; i++) {
2249
                vc1_apply_p_h_loop_filter(v, i);
2250
            }
2251
        }
2252
    }
2253
}
2254

  
2113 2255
/** Decode one P-frame MB (in Simple/Main profile)
2114 2256
 */
2115 2257
static int vc1_decode_p_mb(VC1Context *v)
......
2129 2271
    int first_block = 1;
2130 2272
    int dst_idx, off;
2131 2273
    int skipped, fourmv;
2132
    int block_cbp = 0, pat;
2133
    int apply_loop_filter;
2274
    int block_cbp = 0, pat, block_tt = 0, block_intra = 0;
2134 2275

  
2135 2276
    mquant = v->pq; /* Loosy initialization */
2136 2277

  
......
2143 2284
    else
2144 2285
        skipped = v->s.mbskip_table[mb_pos];
2145 2286

  
2146
    apply_loop_filter = s->loop_filter && !(s->avctx->skip_loop_filter >= AVDISCARD_NONKEY);
2147 2287
    if (!fourmv) /* 1MV mode */
2148 2288
    {
2149 2289
        if (!skipped)
......
2157 2297
                s->current_picture.motion_val[1][s->block_index[0]][1] = 0;
2158 2298
            }
2159 2299
            s->current_picture.mb_type[mb_pos] = s->mb_intra ? MB_TYPE_INTRA : MB_TYPE_16x16;
2160
            vc1_pred_mv(s, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, v->mb_type[0]);
2300
            vc1_pred_mv(v, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, v->mb_type[0]);
2161 2301

  
2162 2302
            /* FIXME Set DC val for inter block ? */
2163 2303
            if (s->mb_intra && !mb_has_coeffs)
......
2211 2351
                        if(v->a_avail)
2212 2352
                            v->vc1dsp.vc1_v_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);
2213 2353
                    }
2214
                    if(apply_loop_filter && s->mb_x && s->mb_x != (s->mb_width - 1) && s->mb_y && s->mb_y != (s->mb_height - 1)){
2215
                        int left_cbp, top_cbp;
2216
                        if(i & 4){
2217
                            left_cbp = v->cbp[s->mb_x - 1]            >> (i * 4);
2218
                            top_cbp  = v->cbp[s->mb_x - s->mb_stride] >> (i * 4);
2219
                        }else{
2220
                            left_cbp = (i & 1) ? (cbp >> ((i-1)*4)) : (v->cbp[s->mb_x - 1]           >> ((i+1)*4));
2221
                            top_cbp  = (i & 2) ? (cbp >> ((i-2)*4)) : (v->cbp[s->mb_x - s->mb_stride] >> ((i+2)*4));
2222
                        }
2223
                        if(left_cbp & 0xC)
2224
                            v->vc1dsp.vc1_v_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, v->pq);
2225
                        if(top_cbp  & 0xA)
2226
                            v->vc1dsp.vc1_h_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, v->pq);
2227
                    }
2228 2354
                    block_cbp |= 0xF << (i << 2);
2355
                    block_intra |= 1 << i;
2229 2356
                } else if(val) {
2230
                    int left_cbp = 0, top_cbp = 0, filter = 0;
2231
                    if(apply_loop_filter && s->mb_x && s->mb_x != (s->mb_width - 1) && s->mb_y && s->mb_y != (s->mb_height - 1)){
2232
                        filter = 1;
2233
                        if(i & 4){
2234
                            left_cbp = v->cbp[s->mb_x - 1]            >> (i * 4);
2235
                            top_cbp  = v->cbp[s->mb_x - s->mb_stride] >> (i * 4);
2236
                        }else{
2237
                            left_cbp = (i & 1) ? (cbp >> ((i-1)*4)) : (v->cbp[s->mb_x - 1]           >> ((i+1)*4));
2238
                            top_cbp  = (i & 2) ? (cbp >> ((i-2)*4)) : (v->cbp[s->mb_x - s->mb_stride] >> ((i+2)*4));
2239
                        }
2240
                        if(left_cbp & 0xC)
2241
                            v->vc1dsp.vc1_v_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, v->pq);
2242
                        if(top_cbp  & 0xA)
2243
                            v->vc1dsp.vc1_h_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, v->pq);
2244
                    }
2245
                    pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block, s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize, (i&4) && (s->flags & CODEC_FLAG_GRAY), filter, left_cbp, top_cbp);
2357
                    pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block, s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize, (i&4) && (s->flags & CODEC_FLAG_GRAY), &block_tt);
2246 2358
                    block_cbp |= pat << (i << 2);
2247 2359
                    if(!v->ttmbf && ttmb < 8) ttmb = -1;
2248 2360
                    first_block = 0;
......
2258 2370
            }
2259 2371
            s->current_picture.mb_type[mb_pos] = MB_TYPE_SKIP;
2260 2372
            s->current_picture.qscale_table[mb_pos] = 0;
2261
            vc1_pred_mv(s, 0, 0, 0, 1, v->range_x, v->range_y, v->mb_type[0]);
2373
            vc1_pred_mv(v, 0, 0, 0, 1, v->range_x, v->range_y, v->mb_type[0]);
2262 2374
            vc1_mc_1mv(v, 0);
2263
            return 0;
2264 2375
        }
2265 2376
    } //1MV mode
2266 2377
    else //4MV mode
......
2284 2395
                    if(val) {
2285 2396
                        GET_MVDATA(dmv_x, dmv_y);
2286 2397
                    }
2287
                    vc1_pred_mv(s, i, dmv_x, dmv_y, 0, v->range_x, v->range_y, v->mb_type[0]);
2398
                    vc1_pred_mv(v, i, dmv_x, dmv_y, 0, v->range_x, v->range_y, v->mb_type[0]);
2288 2399
                    if(!s->mb_intra) vc1_mc_4mv_luma(v, i);
2289 2400
                    intra_count += s->mb_intra;
2290 2401
                    is_intra[i] = s->mb_intra;
......
2299 2410
                if(!coded_inter) coded_inter = !is_intra[i] & is_coded[i];
2300 2411
            }
2301 2412
            // if there are no coded blocks then don't do anything more
2302
            if(!intra_count && !coded_inter) return 0;
2303 2413
            dst_idx = 0;
2414
            if(!intra_count && !coded_inter)
2415
                goto end;
2304 2416
            GET_MQUANT();
2305 2417
            s->current_picture.qscale_table[mb_pos] = mquant;
2306 2418
            /* test if block is intra and has pred */
......
2344 2456
                        if(v->a_avail)
2345 2457
                            v->vc1dsp.vc1_v_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);
2346 2458
                    }
2347
                    if(v->s.loop_filter && s->mb_x && s->mb_x != (s->mb_width - 1) && s->mb_y && s->mb_y != (s->mb_height - 1)){
2348
                        int left_cbp, top_cbp;
2349
                        if(i & 4){
2350
                            left_cbp = v->cbp[s->mb_x - 1]            >> (i * 4);
2351
                            top_cbp  = v->cbp[s->mb_x - s->mb_stride] >> (i * 4);
2352
                        }else{
2353
                            left_cbp = (i & 1) ? (cbp >> ((i-1)*4)) : (v->cbp[s->mb_x - 1]           >> ((i+1)*4));
2354
                            top_cbp  = (i & 2) ? (cbp >> ((i-2)*4)) : (v->cbp[s->mb_x - s->mb_stride] >> ((i+2)*4));
2355
                        }
2356
                        if(left_cbp & 0xC)
2357
                            v->vc1dsp.vc1_v_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, v->pq);
2358
                        if(top_cbp  & 0xA)
2359
                            v->vc1dsp.vc1_h_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, v->pq);
2360
                    }
2361 2459
                    block_cbp |= 0xF << (i << 2);
2460
                    block_intra |= 1 << i;
2362 2461
                } else if(is_coded[i]) {
2363
                    int left_cbp = 0, top_cbp = 0, filter = 0;
2364
                    if(v->s.loop_filter && s->mb_x && s->mb_x != (s->mb_width - 1) && s->mb_y && s->mb_y != (s->mb_height - 1)){
2365
                        filter = 1;
2366
                        if(i & 4){
2367
                            left_cbp = v->cbp[s->mb_x - 1]            >> (i * 4);
2368
                            top_cbp  = v->cbp[s->mb_x - s->mb_stride] >> (i * 4);
2369
                        }else{
2370
                            left_cbp = (i & 1) ? (cbp >> ((i-1)*4)) : (v->cbp[s->mb_x - 1]           >> ((i+1)*4));
2371
                            top_cbp  = (i & 2) ? (cbp >> ((i-2)*4)) : (v->cbp[s->mb_x - s->mb_stride] >> ((i+2)*4));
2372
                        }
2373
                        if(left_cbp & 0xC)
2374
                            v->vc1dsp.vc1_v_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, v->pq);
2375
                        if(top_cbp  & 0xA)
2376
                            v->vc1dsp.vc1_h_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, v->pq);
2377
                    }
2378
                    pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block, s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize, (i&4) && (s->flags & CODEC_FLAG_GRAY), filter, left_cbp, top_cbp);
2462
                    pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block, s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize, (i&4) && (s->flags & CODEC_FLAG_GRAY), &block_tt);
2379 2463
                    block_cbp |= pat << (i << 2);
2380 2464
                    if(!v->ttmbf && ttmb < 8) ttmb = -1;
2381 2465
                    first_block = 0;
2382 2466
                }
2383 2467
            }
2384
            return 0;
2385 2468
        }
2386 2469
        else //Skipped MB
2387 2470
        {
......
2393 2476
            }
2394 2477
            for (i=0; i<4; i++)
2395 2478
            {
2396
                vc1_pred_mv(s, i, 0, 0, 0, v->range_x, v->range_y, v->mb_type[0]);
2479
                vc1_pred_mv(v, i, 0, 0, 0, v->range_x, v->range_y, v->mb_type[0]);
2397 2480
                vc1_mc_4mv_luma(v, i);
2398 2481
            }
2399 2482
            vc1_mc_4mv_chroma(v);
2400 2483
            s->current_picture.qscale_table[mb_pos] = 0;
2401
            return 0;
2402 2484
        }
2403 2485
    }
2486
end:
2404 2487
    v->cbp[s->mb_x] = block_cbp;
2488
    v->ttblk[s->mb_x] = block_tt;
2489
    v->is_intra[s->mb_x] = block_intra;
2405 2490

  
2406
    /* Should never happen */
2407
    return -1;
2491
    return 0;
2408 2492
}
2409 2493

  
2410 2494
/** Decode one B-frame MB (in Main profile)
......
2546 2630
                       i & 4 ? s->uvlinesize : s->linesize,
2547 2631
                       s->block[i]);
2548 2632
        } else if(val) {
2549
            vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block, s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize, (i&4) && (s->flags & CODEC_FLAG_GRAY), 0, 0, 0);
2633
            vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block, s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize, (i&4) && (s->flags & CODEC_FLAG_GRAY), NULL);
2550 2634
            if(!v->ttmbf && ttmb < 8) ttmb = -1;
2551 2635
            first_block = 0;
2552 2636
        }
......
2841 2925
static void vc1_decode_p_blocks(VC1Context *v, int mby_start, int mby_end)
2842 2926
{
2843 2927
    MpegEncContext *s = &v->s;
2928
    int apply_loop_filter;
2844 2929

  
2845 2930
    /* select codingmode used for VLC tables selection */
2846 2931
    switch(v->c_ac_table_index){
......
2867 2952
        break;
2868 2953
    }
2869 2954

  
2955
    apply_loop_filter = s->loop_filter && !(s->avctx->skip_loop_filter >= AVDISCARD_NONKEY);
2870 2956
    s->first_slice_line = 1;
2871 2957
    memset(v->cbp_base, 0, sizeof(v->cbp_base[0])*2*s->mb_stride);
2872 2958
    for(s->mb_y = mby_start; s->mb_y < mby_end; s->mb_y++) {
......
2876 2962
            ff_update_block_index(s);
2877 2963

  
2878 2964
            vc1_decode_p_mb(v);
2965
            if (s->mb_y != mby_start && apply_loop_filter)
2966
                vc1_apply_p_loop_filter(v);
2879 2967
            if(get_bits_count(&s->gb) > v->bits || get_bits_count(&s->gb) < 0) {
2880 2968
                ff_er_add_slice(s, 0, mby_start, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END));
2881 2969
                av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i at %ix%i\n", get_bits_count(&s->gb), v->bits,s->mb_x,s->mb_y);
......
2883 2971
            }
2884 2972
        }
2885 2973
        memmove(v->cbp_base, v->cbp, sizeof(v->cbp_base[0])*s->mb_stride);
2886
        ff_draw_horiz_band(s, s->mb_y * 16, 16);
2974
        memmove(v->ttblk_base, v->ttblk, sizeof(v->ttblk_base[0])*s->mb_stride);
2975
        memmove(v->is_intra_base, v->is_intra, sizeof(v->is_intra_base[0])*s->mb_stride);
2976
        memmove(v->luma_mv_base, v->luma_mv, sizeof(v->luma_mv_base[0])*s->mb_stride);
2977
        if (s->mb_y != mby_start) ff_draw_horiz_band(s, (s->mb_y-1) * 16, 16);
2887 2978
        s->first_slice_line = 0;
2888 2979
    }
2980
    if (apply_loop_filter) {
2981
        s->mb_x = 0;
2982
        ff_init_block_index(s);
2983
        for (; s->mb_x < s->mb_width; s->mb_x++) {
2984
            ff_update_block_index(s);
2985
            vc1_apply_p_loop_filter(v);
2986
        }
2987
    }
2988
    if (mby_end >= mby_start)
2989
        ff_draw_horiz_band(s, (mby_end-1) * 16, 16);
2889 2990
    ff_er_add_slice(s, 0, mby_start, s->mb_width - 1, mby_end - 1, (AC_END|DC_END|MV_END));
2890 2991
}
2891 2992

  
......
3122 3223

  
3123 3224
    v->cbp_base = av_malloc(sizeof(v->cbp_base[0]) * 2 * s->mb_stride);
3124 3225
    v->cbp = v->cbp_base + s->mb_stride;
3226
    v->ttblk_base = av_malloc(sizeof(v->ttblk_base[0]) * 2 * s->mb_stride);
3227
    v->ttblk = v->ttblk_base + s->mb_stride;
3228
    v->is_intra_base = av_malloc(sizeof(v->is_intra_base[0]) * 2 * s->mb_stride);
3229
    v->is_intra = v->is_intra_base + s->mb_stride;
3230
    v->luma_mv_base = av_malloc(sizeof(v->luma_mv_base[0]) * 2 * s->mb_stride);
3231
    v->luma_mv = v->luma_mv_base + s->mb_stride;
3125 3232

  
3126 3233
    /* allocate block type info in that way so it could be used with s->block_index[] */
3127 3234
    v->mb_type_base = av_malloc(s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2);
......
3375 3482
    av_freep(&v->over_flags_plane);
3376 3483
    av_freep(&v->mb_type_base);
3377 3484
    av_freep(&v->cbp_base);
3485
    av_freep(&v->ttblk_base);
3486
    av_freep(&v->is_intra_base); // FIXME use v->mb_type[]
3487
    av_freep(&v->luma_mv_base);
3378 3488
    ff_intrax8_common_end(&v->x8);
3379 3489
    return 0;
3380 3490
}
tests/ref/fate/vc1
2 2
0, 3600, 38016, 0xf4715db5
3 3
0, 7200, 38016, 0xf4715db5
4 4
0, 10800, 38016, 0xf46af0e1
5
0, 14400, 38016, 0x96992cf1
6
0, 18000, 38016, 0xbaadd874
7
0, 21600, 38016, 0x751f4328
8
0, 25200, 38016, 0x751f4328
9
0, 28800, 38016, 0xf7294772
10
0, 32400, 38016, 0xf7294772
11
0, 36000, 38016, 0xf1d12133
12
0, 39600, 38016, 0xf1d12133
13
0, 43200, 38016, 0xf1d12133
14
0, 46800, 38016, 0xf1d12133
15
0, 50400, 38016, 0xf1d12133
5
0, 14400, 38016, 0x9c1c2cf1
6
0, 18000, 38016, 0xff12d87f
7
0, 21600, 38016, 0x7408432b
8
0, 25200, 38016, 0x7408432b
9
0, 28800, 38016, 0x8d11479a
10
0, 32400, 38016, 0x8d11479a
11
0, 36000, 38016, 0xc4a121ab
12
0, 39600, 38016, 0xc4a121ab
13
0, 43200, 38016, 0xc4a121ab
14
0, 46800, 38016, 0xc4a121ab
15
0, 50400, 38016, 0xc4a121ab

Also available in: Unified diff