Revision 5d2b15b8 libavcodec/cavs.h

View differences:

libavcodec/cavs.h
240 240
extern const vector_t ff_cavs_un_mv;
241 241
extern const vector_t ff_cavs_dir_mv;
242 242

  
243
static inline void load_intra_pred_luma(AVSContext *h, uint8_t *top,
244
                                        uint8_t **left, int block) {
245
    int i;
246

  
247
    switch(block) {
248
    case 0:
249
        *left = h->left_border_y;
250
        h->left_border_y[0] = h->left_border_y[1];
251
        memset(&h->left_border_y[17],h->left_border_y[16],9);
252
        memcpy(&top[1],&h->top_border_y[h->mbx*16],16);
253
        top[17] = top[16];
254
        top[0] = top[1];
255
        if((h->flags & A_AVAIL) && (h->flags & B_AVAIL))
256
            h->left_border_y[0] = top[0] = h->topleft_border_y;
257
        break;
258
    case 1:
259
        *left = h->intern_border_y;
260
        for(i=0;i<8;i++)
261
            h->intern_border_y[i+1] = *(h->cy + 7 + i*h->l_stride);
262
        memset(&h->intern_border_y[9],h->intern_border_y[8],9);
263
        h->intern_border_y[0] = h->intern_border_y[1];
264
        memcpy(&top[1],&h->top_border_y[h->mbx*16+8],8);
265
        if(h->flags & C_AVAIL)
266
            memcpy(&top[9],&h->top_border_y[(h->mbx + 1)*16],8);
267
        else
268
            memset(&top[9],top[8],9);
269
        top[17] = top[16];
270
        top[0] = top[1];
271
        if(h->flags & B_AVAIL)
272
            h->intern_border_y[0] = top[0] = h->top_border_y[h->mbx*16+7];
273
        break;
274
    case 2:
275
        *left = &h->left_border_y[8];
276
        memcpy(&top[1],h->cy + 7*h->l_stride,16);
277
        top[17] = top[16];
278
        top[0] = top[1];
279
        if(h->flags & A_AVAIL)
280
            top[0] = h->left_border_y[8];
281
        break;
282
    case 3:
283
        *left = &h->intern_border_y[8];
284
        for(i=0;i<8;i++)
285
            h->intern_border_y[i+9] = *(h->cy + 7 + (i+8)*h->l_stride);
286
        memset(&h->intern_border_y[17],h->intern_border_y[16],9);
287
        memcpy(&top[0],h->cy + 7 + 7*h->l_stride,9);
288
        memset(&top[9],top[8],9);
289
        break;
290
    }
291
}
292

  
293
static inline void load_intra_pred_chroma(AVSContext *h) {
294
    /* extend borders by one pixel */
295
    h->left_border_u[9] = h->left_border_u[8];
296
    h->left_border_v[9] = h->left_border_v[8];
297
    h->top_border_u[h->mbx*10+9] = h->top_border_u[h->mbx*10+8];
298
    h->top_border_v[h->mbx*10+9] = h->top_border_v[h->mbx*10+8];
299
    if(h->mbx && h->mby) {
300
        h->top_border_u[h->mbx*10] = h->left_border_u[0] = h->topleft_border_u;
301
        h->top_border_v[h->mbx*10] = h->left_border_v[0] = h->topleft_border_v;
302
    } else {
303
        h->left_border_u[0] = h->left_border_u[1];
304
        h->left_border_v[0] = h->left_border_v[1];
305
        h->top_border_u[h->mbx*10] = h->top_border_u[h->mbx*10+1];
306
        h->top_border_v[h->mbx*10] = h->top_border_v[h->mbx*10+1];
307
    }
308
}
309

  
310 243
static inline void modify_pred(const int_fast8_t *mod_table, int *mode) {
311 244
    *mode = mod_table[*mode];
312 245
    if(*mode < 0) {
......
315 248
    }
316 249
}
317 250

  
318
static inline void modify_mb_i(AVSContext *h, int *pred_mode_uv) {
319
    /* save pred modes before they get modified */
320
    h->pred_mode_Y[3] =  h->pred_mode_Y[5];
321
    h->pred_mode_Y[6] =  h->pred_mode_Y[8];
322
    h->top_pred_Y[h->mbx*2+0] = h->pred_mode_Y[7];
323
    h->top_pred_Y[h->mbx*2+1] = h->pred_mode_Y[8];
324

  
325
    /* modify pred modes according to availability of neighbour samples */
326
    if(!(h->flags & A_AVAIL)) {
327
        modify_pred(ff_left_modifier_l, &h->pred_mode_Y[4] );
328
        modify_pred(ff_left_modifier_l, &h->pred_mode_Y[7] );
329
        modify_pred(ff_left_modifier_c, pred_mode_uv );
330
    }
331
    if(!(h->flags & B_AVAIL)) {
332
        modify_pred(ff_top_modifier_l, &h->pred_mode_Y[4] );
333
        modify_pred(ff_top_modifier_l, &h->pred_mode_Y[5] );
334
        modify_pred(ff_top_modifier_c, pred_mode_uv );
335
    }
336
}
337

  
338 251
static inline void set_intra_mode_default(AVSContext *h) {
339 252
    h->pred_mode_Y[3] =  h->pred_mode_Y[6] = INTRA_L_LP;
340 253
    h->top_pred_Y[h->mbx*2+0] = h->top_pred_Y[h->mbx*2+1] = INTRA_L_LP;
......
363 276
        *h->col_type = I_8X8;
364 277
}
365 278

  
366

  
367
/**
368
 * initialise predictors for motion vectors and intra prediction
369
 */
370
static inline void init_mb(AVSContext *h) {
371
    int i;
372

  
373
    /* copy predictors from top line (MB B and C) into cache */
374
    for(i=0;i<3;i++) {
375
        h->mv[MV_FWD_B2+i] = h->top_mv[0][h->mbx*2+i];
376
        h->mv[MV_BWD_B2+i] = h->top_mv[1][h->mbx*2+i];
377
    }
378
    h->pred_mode_Y[1] = h->top_pred_Y[h->mbx*2+0];
379
    h->pred_mode_Y[2] = h->top_pred_Y[h->mbx*2+1];
380
    /* clear top predictors if MB B is not available */
381
    if(!(h->flags & B_AVAIL)) {
382
        h->mv[MV_FWD_B2] = ff_cavs_un_mv;
383
        h->mv[MV_FWD_B3] = ff_cavs_un_mv;
384
        h->mv[MV_BWD_B2] = ff_cavs_un_mv;
385
        h->mv[MV_BWD_B3] = ff_cavs_un_mv;
386
        h->pred_mode_Y[1] = h->pred_mode_Y[2] = NOT_AVAIL;
387
        h->flags &= ~(C_AVAIL|D_AVAIL);
388
    } else if(h->mbx) {
389
        h->flags |= D_AVAIL;
390
    }
391
    if(h->mbx == h->mb_width-1) //MB C not available
392
        h->flags &= ~C_AVAIL;
393
    /* clear top-right predictors if MB C is not available */
394
    if(!(h->flags & C_AVAIL)) {
395
        h->mv[MV_FWD_C2] = ff_cavs_un_mv;
396
        h->mv[MV_BWD_C2] = ff_cavs_un_mv;
397
    }
398
    /* clear top-left predictors if MB D is not available */
399
    if(!(h->flags & D_AVAIL)) {
400
        h->mv[MV_FWD_D3] = ff_cavs_un_mv;
401
        h->mv[MV_BWD_D3] = ff_cavs_un_mv;
402
    }
403
    /* set pointer for co-located macroblock type */
404
    h->col_type = &h->col_type_base[h->mby*h->mb_width + h->mbx];
405
}
406

  
407
/**
408
 * save predictors for later macroblocks and increase
409
 * macroblock address
410
 * @returns 0 if end of frame is reached, 1 otherwise
411
 */
412
static inline int next_mb(AVSContext *h) {
413
    int i;
414

  
415
    h->flags |= A_AVAIL;
416
    h->cy += 16;
417
    h->cu += 8;
418
    h->cv += 8;
419
    /* copy mvs as predictors to the left */
420
    for(i=0;i<=20;i+=4)
421
        h->mv[i] = h->mv[i+2];
422
    /* copy bottom mvs from cache to top line */
423
    h->top_mv[0][h->mbx*2+0] = h->mv[MV_FWD_X2];
424
    h->top_mv[0][h->mbx*2+1] = h->mv[MV_FWD_X3];
425
    h->top_mv[1][h->mbx*2+0] = h->mv[MV_BWD_X2];
426
    h->top_mv[1][h->mbx*2+1] = h->mv[MV_BWD_X3];
427
    /* next MB address */
428
    h->mbx++;
429
    if(h->mbx == h->mb_width) { //new mb line
430
        h->flags = B_AVAIL|C_AVAIL;
431
        /* clear left pred_modes */
432
        h->pred_mode_Y[3] = h->pred_mode_Y[6] = NOT_AVAIL;
433
        /* clear left mv predictors */
434
        for(i=0;i<=20;i+=4)
435
            h->mv[i] = ff_cavs_un_mv;
436
        h->mbx = 0;
437
        h->mby++;
438
        /* re-calculate sample pointers */
439
        h->cy = h->picture.data[0] + h->mby*16*h->l_stride;
440
        h->cu = h->picture.data[1] + h->mby*8*h->c_stride;
441
        h->cv = h->picture.data[2] + h->mby*8*h->c_stride;
442
        if(h->mby == h->mb_height) { //frame end
443
            return 0;
444
        } else {
445
            //check_for_slice(h);
446
        }
447
    }
448
    return 1;
449
}
450

  
451 279
static inline int dequant(AVSContext *h, DCTELEM *level_buf, uint8_t *run_buf,
452 280
                          DCTELEM *dst, int mul, int shift, int coeff_num) {
453 281
    int round = 1 << (shift - 1);
......
469 297
}
470 298

  
471 299
void ff_cavs_filter(AVSContext *h, enum mb_t mb_type);
300
void ff_cavs_load_intra_pred_luma(AVSContext *h, uint8_t *top, uint8_t **left,
301
                                  int block);
302
void ff_cavs_load_intra_pred_chroma(AVSContext *h);
303
void ff_cavs_modify_mb_i(AVSContext *h, int *pred_mode_uv);
472 304
void ff_cavs_inter(AVSContext *h, enum mb_t mb_type);
473 305
void ff_cavs_mv(AVSContext *h, enum mv_loc_t nP, enum mv_loc_t nC,
474 306
                enum mv_pred_t mode, enum block_t size, int ref);
307
void ff_cavs_init_mb(AVSContext *h);
308
int  ff_cavs_next_mb(AVSContext *h);
475 309
void ff_cavs_init_pic(AVSContext *h);
476 310
void ff_cavs_init_top_lines(AVSContext *h);
477 311
int ff_cavs_init(AVCodecContext *avctx);

Also available in: Unified diff