Revision 46f2f05f

View differences:

libavcodec/h264.c
408 408
        assert(0);
409 409
}
410 410

  
411
static inline void fill_caches(H264Context *h, int mb_type){
411
static inline void fill_caches(H264Context *h, int mb_type, int for_deblock){
412 412
    MpegEncContext * const s = &h->s;
413 413
    const int mb_xy= s->mb_x + s->mb_y*s->mb_stride;
414 414
    int topleft_xy, top_xy, topright_xy, left_xy[2];
......
435 435
        left_block[3]= 3;
436 436
    }
437 437

  
438
    topleft_type = h->slice_table[topleft_xy ] == h->slice_num ? s->current_picture.mb_type[topleft_xy] : 0;
439
    top_type     = h->slice_table[top_xy     ] == h->slice_num ? s->current_picture.mb_type[top_xy]     : 0;
440
    topright_type= h->slice_table[topright_xy] == h->slice_num ? s->current_picture.mb_type[topright_xy]: 0;
441
    left_type[0] = h->slice_table[left_xy[0] ] == h->slice_num ? s->current_picture.mb_type[left_xy[0]] : 0;
442
    left_type[1] = h->slice_table[left_xy[1] ] == h->slice_num ? s->current_picture.mb_type[left_xy[1]] : 0;
438
    if(for_deblock){
439
        topleft_type = h->slice_table[topleft_xy ] < 255 ? s->current_picture.mb_type[topleft_xy] : 0;
440
        top_type     = h->slice_table[top_xy     ] < 255 ? s->current_picture.mb_type[top_xy]     : 0;
441
        topright_type= h->slice_table[topright_xy] < 255 ? s->current_picture.mb_type[topright_xy]: 0;
442
        left_type[0] = h->slice_table[left_xy[0] ] < 255 ? s->current_picture.mb_type[left_xy[0]] : 0;
443
        left_type[1] = h->slice_table[left_xy[1] ] < 255 ? s->current_picture.mb_type[left_xy[1]] : 0;
444
    }else{
445
        topleft_type = h->slice_table[topleft_xy ] == h->slice_num ? s->current_picture.mb_type[topleft_xy] : 0;
446
        top_type     = h->slice_table[top_xy     ] == h->slice_num ? s->current_picture.mb_type[top_xy]     : 0;
447
        topright_type= h->slice_table[topright_xy] == h->slice_num ? s->current_picture.mb_type[topright_xy]: 0;
448
        left_type[0] = h->slice_table[left_xy[0] ] == h->slice_num ? s->current_picture.mb_type[left_xy[0]] : 0;
449
        left_type[1] = h->slice_table[left_xy[1] ] == h->slice_num ? s->current_picture.mb_type[left_xy[1]] : 0;
450
    }
443 451

  
444 452
    if(IS_INTRA(mb_type)){
445 453
        h->topleft_samples_available= 
......
651 659
                h->ref_cache[list][scan8[0] - 1 + 3*8]= left_type[0] ? LIST_NOT_USED : PART_NOT_AVAILABLE;
652 660
            }
653 661

  
662
            if(for_deblock)
663
                continue;
664

  
654 665
            h->ref_cache[list][scan8[5 ]+1] = 
655 666
            h->ref_cache[list][scan8[7 ]+1] = 
656 667
            h->ref_cache[list][scan8[13]+1] =  //FIXME remove past 3 (init somewher else)
......
2835 2846
    }
2836 2847
    if(h->deblocking_filter) {
2837 2848
        backup_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize);
2849
        fill_caches(h, mb_type, 1); //FIXME dont fill stuff which isnt used by filter_mb
2838 2850
        filter_mb(h, mb_x, mb_y, dest_y, dest_cb, dest_cr);
2839 2851
    }
2840 2852
}
......
3857 3869
        mb_type= MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2|MB_TYPE_SKIP;
3858 3870
        //FIXME mbaff
3859 3871

  
3860
        fill_caches(h, mb_type); //FIXME check what is needed and what not ...
3872
        fill_caches(h, mb_type, 0); //FIXME check what is needed and what not ...
3861 3873
        pred_direct_motion(h, &mb_type);
3862 3874
        if(h->pps.cabac){
3863 3875
            fill_rectangle(h->mvd_cache[0][scan8[0]], 4, 4, 8, 0, 4);
......
3875 3887
        if(h->mb_field_decoding_flag)
3876 3888
            mb_type|= MB_TYPE_INTERLACED;
3877 3889
        
3878
        fill_caches(h, mb_type); //FIXME check what is needed and what not ...
3890
        fill_caches(h, mb_type, 0); //FIXME check what is needed and what not ...
3879 3891
        pred_pskip_motion(h, &mx, &my);
3880 3892
        fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, 0, 1);
3881 3893
        fill_rectangle(  h->mv_cache[0][scan8[0]], 4, 4, 8, pack16to32(mx,my), 4);
......
3994 4006
        return 0;
3995 4007
    }
3996 4008
        
3997
    fill_caches(h, mb_type);
4009
    fill_caches(h, mb_type, 0);
3998 4010

  
3999 4011
    //mb_pred
4000 4012
    if(IS_INTRA(mb_type)){
......
4890 4902
        return -1;
4891 4903
    }
4892 4904

  
4893
    fill_caches(h, mb_type);
4905
    fill_caches(h, mb_type, 0);
4894 4906

  
4895 4907
    if( IS_INTRA( mb_type ) ) {
4896 4908
        if( IS_INTRA4x4( mb_type ) ) {
......
5546 5558
                bS[0] = bS[1] = bS[2] = bS[3] = ( edge == 0 ? 4 : 3 );
5547 5559
            } else {
5548 5560
                int i;
5549
                const int slice_boundary = (h->slice_table[mbn_xy] != h->slice_table[mb_xy]);
5550 5561
                for( i = 0; i < 4; i++ ) {
5551 5562
                    int x = dir == 0 ? edge : i;
5552 5563
                    int y = dir == 0 ? i    : edge;
5553 5564
                    int b_idx= 8 + 4 + x + 8*y;
5554 5565
                    int bn_idx= b_idx - (dir ? 8:1);
5555
                    uint8_t left_non_zero_count;
5556
                    if (slice_boundary) {
5557
                        // must not use non_zero_count_cache, it is not valid
5558
                        // across slice boundaries
5559
                        if (0 == dir) {
5560
                            left_non_zero_count = h->non_zero_count[mbn_xy][6-i];
5561
                        } else {
5562
                            left_non_zero_count = h->non_zero_count[mbn_xy][i];
5563
                        }
5564
                    } else {
5565
                        left_non_zero_count = h->non_zero_count_cache[bn_idx];
5566
                    }
5567 5566

  
5568 5567
                    if( h->non_zero_count_cache[b_idx] != 0 ||
5569
                        left_non_zero_count != 0 ) {
5568
                        h->non_zero_count_cache[bn_idx] != 0 ) {
5570 5569
                        bS[i] = 2;
5571 5570
                    }
5572 5571
                    else if( h->slice_type == P_TYPE ) {
5573
                        int16_t left_mv[2];
5574
                        int8_t  left_ref;
5575
                        if (slice_boundary) {
5576
                            // must not use ref_cache and mv_cache, they are not 
5577
                            // valid across slice boundaries
5578
                            if (dir == 0) {
5579
                                left_ref = s->current_picture.ref_index[0][h->mb2b8_xy[mbn_xy] + (i>>1) * h->b8_stride + 1];
5580
                                *(uint32_t*)left_mv = *(uint32_t*)s->current_picture.motion_val[0][h->mb2b_xy[mbn_xy]+i*h->b_stride+3];
5581
                            } else {
5582
                                left_ref = s->current_picture.ref_index[0][h->mb2b8_xy[mbn_xy] + (i>>1) + h->b8_stride];
5583
                                *(uint32_t*)left_mv = *(uint32_t*)s->current_picture.motion_val[0][h->mb2b_xy[mbn_xy]+3*h->b_stride+i];
5584
                            }
5585
                        } else {
5586
                            left_ref = h->ref_cache[0][bn_idx];
5587
                            *(uint32_t*)left_mv = *(uint32_t*)h->mv_cache[0][bn_idx];
5588
                        }
5589
                        if( h->ref_cache[0][b_idx] != left_ref ||
5590
                            ABS( h->mv_cache[0][b_idx][0] - left_mv[0] ) >= 4 ||
5591
                            ABS( h->mv_cache[0][b_idx][1] - left_mv[1] ) >= 4 )
5572
                        if( h->ref_cache[0][b_idx] != h->ref_cache[0][bn_idx] ||
5573
                            ABS( h->mv_cache[0][b_idx][0] - h->mv_cache[0][bn_idx][0] ) >= 4 ||
5574
                            ABS( h->mv_cache[0][b_idx][1] - h->mv_cache[0][bn_idx][1] ) >= 4 )
5592 5575
                            bS[i] = 1;
5593 5576
                        else
5594 5577
                            bS[i] = 0;

Also available in: Unified diff