Revision 5e5c247a libavcodec/xvmcvideo.c

View differences:

libavcodec/xvmcvideo.c
55 55

  
56 56
void XVMC_pack_pblocks(MpegEncContext *s, int cbp){
57 57
int i,j;
58
#define numblocks 6
59 58

  
60 59
    j=0;
61
    for(i=0;i<numblocks;i++){
62
        if(cbp & (1<<(numblocks-1-i)) ){
60
    for(i=0;i<6;i++){
61
        if(cbp & (1<<(5-i)) ){
63 62
           s->pblocks[i] = (short *)(&s->block[(j++)]);
64 63
        }else{
65 64
           s->pblocks[i] = NULL;
66 65
        }
67 66
//        printf("s->pblocks[%d]=%p ,s->block=%p cbp=%d\n",i,s->pblocks[i],s->block,cbp);
68 67
    }
68
    if (s->chroma_format >= 2){
69
        if (s->chroma_format == 2){//CHROMA_422
70
            for(i=6;i<8;i++){
71
                if(cbp & (1<<(6+7-i)) ){
72
                    s->pblocks[i] = (short *)(&s->block[(j++)]);
73
                }else{
74
                    s->pblocks[i] = NULL;
75
                }
76
            }
77
        }else{//CHROMA_444
78
            for(i=6; i<12; i++){
79
                if(cbp & (1<<(6+11-i)) ){
80
                    s->pblocks[i] = (short *)(&s->block[(j++)]);
81
                }else{
82
                    s->pblocks[i] = NULL;
83
                }
84
            }
85
	}
86
    }
69 87
}
70 88

  
71
static int calc_cbp(MpegEncContext *s, int blocknum){
89
static int calc_cbp(MpegEncContext *s){
72 90
/* compute cbp */
73
// for I420 bit_offset=5
74 91
int  i,cbp = 0;
75
    for(i=0; i<blocknum; i++) {
92
    for(i=0; i<4; i++) {
76 93
        if(s->block_last_index[i] >= 0)
77 94
            cbp |= 1 << (5 - i);
78 95
    }
96
    if(s->flags & CODEC_FLAG_GRAY)
97
         return cbp; //4 block for grayscale one done
98

  
99

  
100
    for(i=4; i<6; i++) {
101
        if(s->block_last_index[i] >= 0)
102
            cbp |= 1 << (5 - i);
103
    }
104
    if(s->chroma_format <  2) return cbp;
105

  
106

  
107
    if(s->chroma_format == 2){/*CHROMA_422*/
108
        for(i=6; i<8; i++) {
109
            if(s->block_last_index[i] >= 0)
110
                cbp |= 1 << (6+7 - i);
111
        }
112
    }else{/*CHROMA_444*/
113
        for(i=6; i<12; i++) {
114
            if(s->block_last_index[i] >= 0)
115
                cbp |= 1 << (6+11 - i);
116
        }
117
    }
79 118
    return cbp;
80 119
}
81 120

  
......
121 160
            assert(last->state & MP_XVMC_STATE_PREDICTION);
122 161
            render->p_past_surface = last->p_surface;
123 162
            return 0;
124
     }
163
    }
125 164

  
126 165
return -1;
127 166
}
......
256 295
    }//!intra
257 296
//time to handle data blocks;
258 297
    mv_block->index = render->next_free_data_block_num;
298

  
259 299
    blocks_per_mb = 6;
260
/*
261
    switch( s->chroma_format){
262
        case CHROMA_422:
263
            blocks_per_mb = 8;
264
            break;
265
        case CHROMA_444:
266
            blocks_per_mb = 12;
267
            break;
300
    if( s->chroma_format >= 2){
301
        block_per_mb = 4 + (1 << (s->chroma_format));
268 302
    }
269
*/
303

  
270 304
    if(s->flags & CODEC_FLAG_GRAY){
271 305
        if(s->mb_intra){//intra frames are alwasy full chroma block
272 306
            for(i=4; i<blocks_per_mb; i++){
......
277 311
        }else
278 312
            blocks_per_mb = 4;//Luminance blocks only
279 313
    }
280
    cbp = calc_cbp(s,blocks_per_mb);
314
    cbp = calc_cbp(s);
281 315
    mv_block->coded_block_pattern = cbp;
282 316
    if(cbp == 0)
283 317
        mv_block->macroblock_type &= ~XVMC_MB_TYPE_PATTERN;

Also available in: Unified diff