Revision b482e2d1 libavcodec/cavs.c

View differences:

libavcodec/cavs.c
76 76
    /* intra prediction is done with un-deblocked samples
77 77
     they are saved here before deblocking the MB  */
78 78
    uint8_t *top_border_y, *top_border_u, *top_border_v;
79
    uint8_t left_border_y[16], left_border_u[8], left_border_v[8];
79
    uint8_t left_border_y[16], left_border_u[10], left_border_v[10];
80 80
    uint8_t topleft_border_y, topleft_border_u, topleft_border_v;
81 81

  
82 82
    void (*intra_pred_l[8])(uint8_t *d,uint8_t *top,uint8_t *left,int stride);
......
136 136
    tc    =    tc_tab[clip(qp_avg + h->alpha_offset,0,63)];
137 137

  
138 138
static void filter_mb(AVSContext *h, enum mb_t mb_type) {
139
    uint8_t bs[8];
139
    DECLARE_ALIGNED_8(uint8_t, bs[8]);
140 140
    int qp_avg, alpha, beta, tc;
141 141
    int i;
142 142

  
143 143
    /* save un-deblocked lines */
144 144
    h->topleft_border_y = h->top_border_y[h->mbx*16+15];
145
    h->topleft_border_u = h->top_border_u[h->mbx*8+7];
146
    h->topleft_border_v = h->top_border_v[h->mbx*8+7];
145
    h->topleft_border_u = h->top_border_u[h->mbx*10+8];
146
    h->topleft_border_v = h->top_border_v[h->mbx*10+8];
147 147
    memcpy(&h->top_border_y[h->mbx*16], h->cy + 15* h->l_stride,16);
148
    memcpy(&h->top_border_u[h->mbx* 8], h->cu +  7* h->c_stride,8);
149
    memcpy(&h->top_border_v[h->mbx* 8], h->cv +  7* h->c_stride,8);
148
    memcpy(&h->top_border_u[h->mbx*10+1], h->cu +  7* h->c_stride,8);
149
    memcpy(&h->top_border_v[h->mbx*10+1], h->cv +  7* h->c_stride,8);
150 150
    for(i=0;i<8;i++) {
151 151
        h->left_border_y[i*2+0] = *(h->cy + 15 + (i*2+0)*h->l_stride);
152 152
        h->left_border_y[i*2+1] = *(h->cy + 15 + (i*2+1)*h->l_stride);
153
        h->left_border_u[i] = *(h->cu + 7 + i*h->c_stride);
154
        h->left_border_v[i] = *(h->cv + 7 + i*h->c_stride);
153
        h->left_border_u[i+1] = *(h->cu + 7 + i*h->c_stride);
154
        h->left_border_v[i+1] = *(h->cv + 7 + i*h->c_stride);
155 155
    }
156 156
    if(!h->loop_filter_disable) {
157 157
        /* clear bs */
......
286 286
    }
287 287
}
288 288

  
289
static inline void load_intra_pred_chroma(uint8_t *stop, uint8_t *sleft,
290
                                          uint8_t stopleft, uint8_t *dtop,
291
                                          uint8_t *dleft, int stride, int flags) {
292
    int i;
293

  
294
    if(flags & A_AVAIL) {
295
        for(i=0; i<8; i++)
296
            dleft[i+1] = sleft[i];
297
        dleft[0] = dleft[1];
298
        dleft[9] = dleft[8];
299
    }
300
    if(flags & B_AVAIL) {
301
        for(i=0; i<8; i++)
302
            dtop[i+1] = stop[i];
303
        dtop[0] = dtop[1];
304
        dtop[9] = dtop[8];
305
        if(flags & A_AVAIL)
306
            dleft[0] = dtop[0] = stopleft;
307
    }
308
}
309

  
310 289
static void intra_pred_vert(uint8_t *d,uint8_t *top,uint8_t *left,int stride) {
311 290
    int y;
312 291
    uint64_t a = *((uint64_t *)(&top[1]));
......
394 373

  
395 374
#undef LOWPASS
396 375

  
397
static inline void modify_pred(const int8_t *mod_table, int *mode) {
376
static inline void modify_pred(const int_fast8_t *mod_table, int *mode) {
398 377
    int newmode = mod_table[*mode];
399 378
    if(newmode < 0) {
400 379
        av_log(NULL, AV_LOG_ERROR, "Illegal intra prediction mode\n");
......
688 667

  
689 668
/* kth-order exponential golomb code */
690 669
static inline int get_ue_code(GetBitContext *gb, int order) {
691
    if(order)
692
        return (get_ue_golomb(gb) << order) + get_bits(gb,order);
670
    if(order) {
671
        int ret = get_ue_golomb(gb) << order;
672
        return ret + get_bits(gb,order);
673
    }
693 674
    return get_ue_golomb(gb);
694 675
}
695 676

  
......
730 711
        run_buf[i] = run;
731 712
    }
732 713
    /* inverse scan and dequantization */
733
    for(i=i-1;i>=0;i--) {
714
    while(--i >= 0){
734 715
        pos += 1 + run_buf[i];
735 716
        if(pos > 63) {
736 717
            av_log(h->s.avctx, AV_LOG_ERROR,
......
920 901
    }
921 902

  
922 903
    /* chroma intra prediction */
923
    load_intra_pred_chroma(&h->top_border_u[h->mbx*8], h->left_border_u,
924
                           h->topleft_border_u, top, left, h->c_stride, h->flags);
925
    h->intra_pred_c[pred_mode_uv](h->cu, top, left, h->c_stride);
926
    load_intra_pred_chroma(&h->top_border_v[h->mbx*8], h->left_border_v,
927
                           h->topleft_border_v, top, left, h->c_stride, h->flags);
928
    h->intra_pred_c[pred_mode_uv](h->cv, top, left, h->c_stride);
904
    /* extend borders by one pixel */
905
    h->left_border_u[9] = h->left_border_u[8];
906
    h->left_border_v[9] = h->left_border_v[8];
907
    h->top_border_u[h->mbx*10+9] = h->top_border_u[h->mbx*10+8];
908
    h->top_border_v[h->mbx*10+9] = h->top_border_v[h->mbx*10+8];
909
    if(h->mbx && h->mby) {
910
        h->top_border_u[h->mbx*10] = h->left_border_u[0] = h->topleft_border_u;
911
        h->top_border_v[h->mbx*10] = h->left_border_v[0] = h->topleft_border_v;
912
    } else {
913
        h->left_border_u[0] = h->left_border_u[1];
914
        h->left_border_v[0] = h->left_border_v[1];
915
        h->top_border_u[h->mbx*10] = h->top_border_u[h->mbx*10+1];
916
        h->top_border_v[h->mbx*10] = h->top_border_v[h->mbx*10+1];
917
    }
918
    h->intra_pred_c[pred_mode_uv](h->cu, &h->top_border_u[h->mbx*10],
919
                                  h->left_border_u, h->c_stride);
920
    h->intra_pred_c[pred_mode_uv](h->cv, &h->top_border_v[h->mbx*10],
921
                                  h->left_border_v, h->c_stride);
929 922

  
930 923
    decode_residual_chroma(h);
931 924
    filter_mb(h,I_8X8);
......
1324 1317
    h->top_qp       = av_malloc( h->mb_width);
1325 1318
    h->top_mv[0]    = av_malloc((h->mb_width*2+1)*sizeof(vector_t));
1326 1319
    h->top_mv[1]    = av_malloc((h->mb_width*2+1)*sizeof(vector_t));
1327
    h->top_pred_Y   = av_malloc( h->mb_width*2*sizeof(int));
1320
    h->top_pred_Y   = av_malloc( h->mb_width*2*sizeof(*h->top_pred_Y));
1328 1321
    h->top_border_y = av_malloc((h->mb_width+1)*16);
1329
    h->top_border_u = av_malloc((h->mb_width+1)*8);
1330
    h->top_border_v = av_malloc((h->mb_width+1)*8);
1322
    h->top_border_u = av_malloc((h->mb_width)*10);
1323
    h->top_border_v = av_malloc((h->mb_width)*10);
1331 1324

  
1332 1325
    /* alloc space for co-located MVs and types */
1333 1326
    h->col_mv       = av_malloc( h->mb_width*h->mb_height*4*sizeof(vector_t));
......
1336 1329

  
1337 1330
static int decode_seq_header(AVSContext *h) {
1338 1331
    MpegEncContext *s = &h->s;
1339
    extern const AVRational frame_rate_tab[];
1332
    extern const AVRational ff_frame_rate_tab[];
1340 1333
    int frame_rate_code;
1341 1334

  
1342 1335
    h->profile =         get_bits(&s->gb,8);
......
1354 1347
    s->low_delay =       get_bits1(&s->gb);
1355 1348
    h->mb_width  = (s->width  + 15) >> 4;
1356 1349
    h->mb_height = (s->height + 15) >> 4;
1357
    h->s.avctx->time_base.den = frame_rate_tab[frame_rate_code].num;
1358
    h->s.avctx->time_base.num = frame_rate_tab[frame_rate_code].den;
1350
    h->s.avctx->time_base.den = ff_frame_rate_tab[frame_rate_code].num;
1351
    h->s.avctx->time_base.num = ff_frame_rate_tab[frame_rate_code].den;
1359 1352
    h->s.avctx->width  = s->width;
1360 1353
    h->s.avctx->height = s->height;
1361 1354
    if(!h->top_qp)
......
1541 1534
    NULL,
1542 1535
    cavs_decode_end,
1543 1536
    cavs_decode_frame,
1544
    CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY, //FIXME is this correct ?
1537
    CODEC_CAP_DR1 | CODEC_CAP_DELAY,
1545 1538
    .flush= ff_cavs_flush,
1546 1539
};

Also available in: Unified diff