Revision 6fbcaaa0

View differences:

libavcodec/h264.c
482 482
                h->intra4x4_pred_mode_cache[7+8*0]= h->intra4x4_pred_mode[top_xy][3];
483 483
            }else{
484 484
                int pred;
485
                if(IS_INTRA16x16(top_type) || (IS_INTER(top_type) && !h->pps.constrained_intra_pred))
486
                    pred= 2;
487
                else{
485
                if(!top_type || (IS_INTER(top_type) && h->pps.constrained_intra_pred))
488 486
                    pred= -1;
487
                else{
488
                    pred= 2;
489 489
                }
490 490
                h->intra4x4_pred_mode_cache[4+8*0]=
491 491
                h->intra4x4_pred_mode_cache[5+8*0]=
......
498 498
                    h->intra4x4_pred_mode_cache[3+8*2 + 2*8*i]= h->intra4x4_pred_mode[left_xy[i]][left_block[1+2*i]];
499 499
                }else{
500 500
                    int pred;
501
                    if(IS_INTRA16x16(left_type[i]) || (IS_INTER(left_type[i]) && !h->pps.constrained_intra_pred))
502
                        pred= 2;
503
                    else{
501
                    if(!left_type[i] || (IS_INTER(left_type[i]) && h->pps.constrained_intra_pred))
504 502
                        pred= -1;
503
                    else{
504
                        pred= 2;
505 505
                    }
506 506
                    h->intra4x4_pred_mode_cache[3+8*1 + 2*8*i]=
507 507
                    h->intra4x4_pred_mode_cache[3+8*2 + 2*8*i]= pred;
......
2739 2739
//        dct_offset = s->linesize * 16;
2740 2740
    }
2741 2741

  
2742
    if (IS_INTRA_PCM(mb_type)) {
2743
        unsigned int x, y;
2744

  
2745
        // The pixels are stored in h->mb array in the same order as levels,
2746
        // copy them in output in the correct order.
2747
        for(i=0; i<16; i++) {
2748
            for (y=0; y<4; y++) {
2749
                for (x=0; x<4; x++) {
2750
                    *(dest_y + h->block_offset[i] + y*linesize + x) = h->mb[i*16+y*4+x];
2751
                }
2752
            }
2753
        }
2754
        for(i=16; i<16+4; i++) {
2755
            for (y=0; y<4; y++) {
2756
                for (x=0; x<4; x++) {
2757
                    *(dest_cb + h->block_offset[i] + y*uvlinesize + x) = h->mb[i*16+y*4+x];
2758
                }
2759
            }
2760
        }
2761
        for(i=20; i<20+4; i++) {
2762
            for (y=0; y<4; y++) {
2763
                for (x=0; x<4; x++) {
2764
                    *(dest_cr + h->block_offset[i] + y*uvlinesize + x) = h->mb[i*16+y*4+x];
2765
                }
2766
            }
2767
        }
2768
        goto deblock;
2769
    }
2742 2770
    if(IS_INTRA(mb_type)){
2743 2771
        if(h->deblocking_filter)
2744 2772
            xchg_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 1);
......
2845 2873
            }
2846 2874
        }
2847 2875
    }
2876
deblock:
2848 2877
    if(h->deblocking_filter) {
2849 2878
        backup_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize);
2850 2879
        fill_caches(h, mb_type, 1); //FIXME dont fill stuff which isnt used by filter_mb
......
3984 4013
    h->slice_table[ mb_xy ]= h->slice_num;
3985 4014
    
3986 4015
    if(IS_INTRA_PCM(mb_type)){
3987
        const uint8_t *ptr;
3988
        int x, y;
4016
        unsigned int x, y;
3989 4017
        
3990 4018
        // we assume these blocks are very rare so we dont optimize it
3991 4019
        align_get_bits(&s->gb);
3992 4020
        
3993
        ptr= s->gb.buffer + get_bits_count(&s->gb);
3994
    
4021
        // The pixels are stored in the same order as levels in h->mb array.
3995 4022
        for(y=0; y<16; y++){
3996
            const int index= 4*(y&3) + 64*(y>>2);
4023
            const int index= 4*(y&3) + 32*((y>>2)&1) + 128*(y>>3);
3997 4024
            for(x=0; x<16; x++){
3998
                h->mb[index + (x&3) + 16*(x>>2)]= *(ptr++);
4025
                tprintf("LUMA ICPM LEVEL (%3d)\n", show_bits(&s->gb, 8));
4026
                h->mb[index + (x&3) + 16*((x>>2)&1) + 64*(x>>3)]= get_bits(&s->gb, 8);
3999 4027
            }
4000 4028
        }
4001 4029
        for(y=0; y<8; y++){
4002 4030
            const int index= 256 + 4*(y&3) + 32*(y>>2);
4003 4031
            for(x=0; x<8; x++){
4004
                h->mb[index + (x&3) + 16*(x>>2)]= *(ptr++);
4032
                tprintf("CHROMA U ICPM LEVEL (%3d)\n", show_bits(&s->gb, 8));
4033
                h->mb[index + (x&3) + 16*(x>>2)]= get_bits(&s->gb, 8);
4005 4034
            }
4006 4035
        }
4007 4036
        for(y=0; y<8; y++){
4008 4037
            const int index= 256 + 64 + 4*(y&3) + 32*(y>>2);
4009 4038
            for(x=0; x<8; x++){
4010
                h->mb[index + (x&3) + 16*(x>>2)]= *(ptr++);
4039
                tprintf("CHROMA V ICPM LEVEL (%3d)\n", show_bits(&s->gb, 8));
4040
                h->mb[index + (x&3) + 16*(x>>2)]= get_bits(&s->gb, 8);
4011 4041
            }
4012 4042
        }
4013 4043
    
4014
        skip_bits(&s->gb, 384); //FIXME check /fix the bitstream readers
4015
        
4016
        //FIXME deblock filter, non_zero_count_cache init ...
4044
        // In deblocking, the quantiser is 0
4045
        s->current_picture.qscale_table[mb_xy]= 0;
4046
        h->chroma_qp = get_chroma_qp(h, 0);
4047
        // All coeffs are presents
4017 4048
        memset(h->non_zero_count[mb_xy], 16, 16);
4018
        s->current_picture.qscale_table[mb_xy]= s->qscale;
4019 4049
        
4020 4050
        return 0;
4021 4051
    }
......
4919 4949
    h->slice_table[ mb_xy ]= h->slice_num;
4920 4950

  
4921 4951
    if(IS_INTRA_PCM(mb_type)) {
4922
        /* TODO */
4923
        assert(0);
4924
        h->cbp_table[mb_xy] = 0xf +4*2; //FIXME ?!
4925
        h->cbp_table[mb_xy] |= 0x1C0;
4952
        const uint8_t *ptr;
4953
        unsigned int x, y;
4954
        
4955
        // We assume these blocks are very rare so we dont optimize it.
4956
        // FIXME The two following lines get the bitstream position in the cabac
4957
        // decode, I think it should be done by a function in cabac.h (or cabac.c).
4958
        ptr= h->cabac.bytestream;
4959
        if (h->cabac.low&0x1) ptr-=CABAC_BITS/8;
4960

  
4961
        // The pixels are stored in the same order as levels in h->mb array.
4962
        for(y=0; y<16; y++){
4963
            const int index= 4*(y&3) + 32*((y>>2)&1) + 128*(y>>3);
4964
            for(x=0; x<16; x++){
4965
                tprintf("LUMA ICPM LEVEL (%3d)\n", *ptr);
4966
                h->mb[index + (x&3) + 16*((x>>2)&1) + 64*(x>>3)]= *ptr++;
4967
            }
4968
        }
4969
        for(y=0; y<8; y++){
4970
            const int index= 256 + 4*(y&3) + 32*(y>>2);
4971
            for(x=0; x<8; x++){
4972
                tprintf("CHROMA U ICPM LEVEL (%3d)\n", *ptr);
4973
                h->mb[index + (x&3) + 16*(x>>2)]= *ptr++;
4974
            }
4975
        }
4976
        for(y=0; y<8; y++){
4977
            const int index= 256 + 64 + 4*(y&3) + 32*(y>>2);
4978
            for(x=0; x<8; x++){
4979
                tprintf("CHROMA V ICPM LEVEL (%3d)\n", *ptr);
4980
                h->mb[index + (x&3) + 16*(x>>2)]= *ptr++;
4981
            }
4982
        }
4983

  
4984
        ff_init_cabac_decoder(&h->cabac, ptr, h->cabac.bytestream_end - ptr);
4985

  
4986
        // All blocks are presents
4987
        h->cbp_table[mb_xy] = 0x1ef;
4926 4988
        h->chroma_pred_mode_table[mb_xy] = 0;
4927
        s->current_picture.qscale_table[mb_xy]= s->qscale;
4928
        return -1;
4989
        // In deblocking, the quantiser is 0
4990
        s->current_picture.qscale_table[mb_xy]= 0;
4991
        h->chroma_qp = get_chroma_qp(h, 0);
4992
        // All coeffs are presents
4993
        memset(h->non_zero_count[mb_xy], 16, 16);
4994
        return 0;
4929 4995
    }
4930 4996

  
4931 4997
    fill_caches(h, mb_type, 0);
......
5605 5671
            }
5606 5672

  
5607 5673
            /* Filter edge */
5608
            qp = ( s->qscale + s->current_picture.qscale_table[mbn_xy] + 1 ) >> 1;
5674
            // Do not use s->qscale as luma quantiser because it has not the same
5675
            // value in IPCM macroblocks.
5676
            qp = ( s->current_picture.qscale_table[mb_xy] + s->current_picture.qscale_table[mbn_xy] + 1 ) >> 1;
5609 5677
            //tprintf("filter mb:%d/%d dir:%d edge:%d, QPy:%d, QPc:%d, QPcn:%d\n", mb_x, mb_y, dir, edge, qp, h->chroma_qp, s->current_picture.qscale_table[mbn_xy]);
5610 5678
            if( dir == 0 ) {
5611 5679
                filter_mb_edgev( h, &img_y[4*edge], linesize, bS, qp );

Also available in: Unified diff