Revision 5d2b15b8 libavcodec/cavs.c

View differences:

libavcodec/cavs.c
143 143
 *
144 144
 ****************************************************************************/
145 145

  
146
void ff_cavs_load_intra_pred_luma(AVSContext *h, uint8_t *top,
147
                                        uint8_t **left, int block) {
148
    int i;
149

  
150
    switch(block) {
151
    case 0:
152
        *left = h->left_border_y;
153
        h->left_border_y[0] = h->left_border_y[1];
154
        memset(&h->left_border_y[17],h->left_border_y[16],9);
155
        memcpy(&top[1],&h->top_border_y[h->mbx*16],16);
156
        top[17] = top[16];
157
        top[0] = top[1];
158
        if((h->flags & A_AVAIL) && (h->flags & B_AVAIL))
159
            h->left_border_y[0] = top[0] = h->topleft_border_y;
160
        break;
161
    case 1:
162
        *left = h->intern_border_y;
163
        for(i=0;i<8;i++)
164
            h->intern_border_y[i+1] = *(h->cy + 7 + i*h->l_stride);
165
        memset(&h->intern_border_y[9],h->intern_border_y[8],9);
166
        h->intern_border_y[0] = h->intern_border_y[1];
167
        memcpy(&top[1],&h->top_border_y[h->mbx*16+8],8);
168
        if(h->flags & C_AVAIL)
169
            memcpy(&top[9],&h->top_border_y[(h->mbx + 1)*16],8);
170
        else
171
            memset(&top[9],top[8],9);
172
        top[17] = top[16];
173
        top[0] = top[1];
174
        if(h->flags & B_AVAIL)
175
            h->intern_border_y[0] = top[0] = h->top_border_y[h->mbx*16+7];
176
        break;
177
    case 2:
178
        *left = &h->left_border_y[8];
179
        memcpy(&top[1],h->cy + 7*h->l_stride,16);
180
        top[17] = top[16];
181
        top[0] = top[1];
182
        if(h->flags & A_AVAIL)
183
            top[0] = h->left_border_y[8];
184
        break;
185
    case 3:
186
        *left = &h->intern_border_y[8];
187
        for(i=0;i<8;i++)
188
            h->intern_border_y[i+9] = *(h->cy + 7 + (i+8)*h->l_stride);
189
        memset(&h->intern_border_y[17],h->intern_border_y[16],9);
190
        memcpy(&top[0],h->cy + 7 + 7*h->l_stride,9);
191
        memset(&top[9],top[8],9);
192
        break;
193
    }
194
}
195

  
196
void ff_cavs_load_intra_pred_chroma(AVSContext *h) {
197
    /* extend borders by one pixel */
198
    h->left_border_u[9] = h->left_border_u[8];
199
    h->left_border_v[9] = h->left_border_v[8];
200
    h->top_border_u[h->mbx*10+9] = h->top_border_u[h->mbx*10+8];
201
    h->top_border_v[h->mbx*10+9] = h->top_border_v[h->mbx*10+8];
202
    if(h->mbx && h->mby) {
203
        h->top_border_u[h->mbx*10] = h->left_border_u[0] = h->topleft_border_u;
204
        h->top_border_v[h->mbx*10] = h->left_border_v[0] = h->topleft_border_v;
205
    } else {
206
        h->left_border_u[0] = h->left_border_u[1];
207
        h->left_border_v[0] = h->left_border_v[1];
208
        h->top_border_u[h->mbx*10] = h->top_border_u[h->mbx*10+1];
209
        h->top_border_v[h->mbx*10] = h->top_border_v[h->mbx*10+1];
210
    }
211
}
212

  
146 213
static void intra_pred_vert(uint8_t *d,uint8_t *top,uint8_t *left,int stride) {
147 214
    int y;
148 215
    uint64_t a = unaligned64(&top[1]);
......
230 297

  
231 298
#undef LOWPASS
232 299

  
300
void ff_cavs_modify_mb_i(AVSContext *h, int *pred_mode_uv) {
301
    /* save pred modes before they get modified */
302
    h->pred_mode_Y[3] =  h->pred_mode_Y[5];
303
    h->pred_mode_Y[6] =  h->pred_mode_Y[8];
304
    h->top_pred_Y[h->mbx*2+0] = h->pred_mode_Y[7];
305
    h->top_pred_Y[h->mbx*2+1] = h->pred_mode_Y[8];
306

  
307
    /* modify pred modes according to availability of neighbour samples */
308
    if(!(h->flags & A_AVAIL)) {
309
        modify_pred(ff_left_modifier_l, &h->pred_mode_Y[4] );
310
        modify_pred(ff_left_modifier_l, &h->pred_mode_Y[7] );
311
        modify_pred(ff_left_modifier_c, pred_mode_uv );
312
    }
313
    if(!(h->flags & B_AVAIL)) {
314
        modify_pred(ff_top_modifier_l, &h->pred_mode_Y[4] );
315
        modify_pred(ff_top_modifier_l, &h->pred_mode_Y[5] );
316
        modify_pred(ff_top_modifier_c, pred_mode_uv );
317
    }
318
}
319

  
233 320
/*****************************************************************************
234 321
 *
235 322
 * motion compensation
......
438 525

  
439 526
/*****************************************************************************
440 527
 *
528
 * macroblock level
529
 *
530
 ****************************************************************************/
531

  
532
/**
533
 * initialise predictors for motion vectors and intra prediction
534
 */
535
void ff_cavs_init_mb(AVSContext *h) {
536
    int i;
537

  
538
    /* copy predictors from top line (MB B and C) into cache */
539
    for(i=0;i<3;i++) {
540
        h->mv[MV_FWD_B2+i] = h->top_mv[0][h->mbx*2+i];
541
        h->mv[MV_BWD_B2+i] = h->top_mv[1][h->mbx*2+i];
542
    }
543
    h->pred_mode_Y[1] = h->top_pred_Y[h->mbx*2+0];
544
    h->pred_mode_Y[2] = h->top_pred_Y[h->mbx*2+1];
545
    /* clear top predictors if MB B is not available */
546
    if(!(h->flags & B_AVAIL)) {
547
        h->mv[MV_FWD_B2] = ff_cavs_un_mv;
548
        h->mv[MV_FWD_B3] = ff_cavs_un_mv;
549
        h->mv[MV_BWD_B2] = ff_cavs_un_mv;
550
        h->mv[MV_BWD_B3] = ff_cavs_un_mv;
551
        h->pred_mode_Y[1] = h->pred_mode_Y[2] = NOT_AVAIL;
552
        h->flags &= ~(C_AVAIL|D_AVAIL);
553
    } else if(h->mbx) {
554
        h->flags |= D_AVAIL;
555
    }
556
    if(h->mbx == h->mb_width-1) //MB C not available
557
        h->flags &= ~C_AVAIL;
558
    /* clear top-right predictors if MB C is not available */
559
    if(!(h->flags & C_AVAIL)) {
560
        h->mv[MV_FWD_C2] = ff_cavs_un_mv;
561
        h->mv[MV_BWD_C2] = ff_cavs_un_mv;
562
    }
563
    /* clear top-left predictors if MB D is not available */
564
    if(!(h->flags & D_AVAIL)) {
565
        h->mv[MV_FWD_D3] = ff_cavs_un_mv;
566
        h->mv[MV_BWD_D3] = ff_cavs_un_mv;
567
    }
568
    /* set pointer for co-located macroblock type */
569
    h->col_type = &h->col_type_base[h->mby*h->mb_width + h->mbx];
570
}
571

  
572
/**
573
 * save predictors for later macroblocks and increase
574
 * macroblock address
575
 * @returns 0 if end of frame is reached, 1 otherwise
576
 */
577
int ff_cavs_next_mb(AVSContext *h) {
578
    int i;
579

  
580
    h->flags |= A_AVAIL;
581
    h->cy += 16;
582
    h->cu += 8;
583
    h->cv += 8;
584
    /* copy mvs as predictors to the left */
585
    for(i=0;i<=20;i+=4)
586
        h->mv[i] = h->mv[i+2];
587
    /* copy bottom mvs from cache to top line */
588
    h->top_mv[0][h->mbx*2+0] = h->mv[MV_FWD_X2];
589
    h->top_mv[0][h->mbx*2+1] = h->mv[MV_FWD_X3];
590
    h->top_mv[1][h->mbx*2+0] = h->mv[MV_BWD_X2];
591
    h->top_mv[1][h->mbx*2+1] = h->mv[MV_BWD_X3];
592
    /* next MB address */
593
    h->mbx++;
594
    if(h->mbx == h->mb_width) { //new mb line
595
        h->flags = B_AVAIL|C_AVAIL;
596
        /* clear left pred_modes */
597
        h->pred_mode_Y[3] = h->pred_mode_Y[6] = NOT_AVAIL;
598
        /* clear left mv predictors */
599
        for(i=0;i<=20;i+=4)
600
            h->mv[i] = ff_cavs_un_mv;
601
        h->mbx = 0;
602
        h->mby++;
603
        /* re-calculate sample pointers */
604
        h->cy = h->picture.data[0] + h->mby*16*h->l_stride;
605
        h->cu = h->picture.data[1] + h->mby*8*h->c_stride;
606
        h->cv = h->picture.data[2] + h->mby*8*h->c_stride;
607
        if(h->mby == h->mb_height) { //frame end
608
            return 0;
609
        } else {
610
            //check_for_slice(h);
611
        }
612
    }
613
    return 1;
614
}
615

  
616
/*****************************************************************************
617
 *
441 618
 * frame level
442 619
 *
443 620
 ****************************************************************************/

Also available in: Unified diff