~ubuntu-branches/ubuntu/trusty/gst-libav1.0/trusty-proposed

« back to all changes in this revision

Viewing changes to gst-libs/ext/libav/libavcodec/rv40.c

  • Committer: Package Import Robot
  • Author(s): Sebastian Dröge
  • Date: 2013-09-24 17:07:00 UTC
  • mfrom: (1.1.17) (7.1.9 experimental)
  • Revision ID: package-import@ubuntu.com-20130924170700-4dg62s3pwl0pdakz
Tags: 1.2.0-1
* New upstream stable release:
  + debian/control:
    - Build depend on GStreamer and gst-plugins-base >= 1.2.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
228
228
    int q, i;
229
229
    int prev_type = 0;
230
230
    int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
231
 
    int blocks[RV34_MB_TYPES] = {0};
232
 
    int count = 0;
233
231
 
234
232
    if(!r->s.mb_skip_run)
235
233
        r->s.mb_skip_run = svq3_get_ue_golomb(gb) + 1;
237
235
    if(--r->s.mb_skip_run)
238
236
         return RV34_MB_SKIP;
239
237
 
240
 
    if(r->avail_cache[6-1])
241
 
        blocks[r->mb_type[mb_pos - 1]]++;
242
238
    if(r->avail_cache[6-4]){
 
239
        int blocks[RV34_MB_TYPES] = {0};
 
240
        int count = 0;
 
241
        if(r->avail_cache[6-1])
 
242
            blocks[r->mb_type[mb_pos - 1]]++;
243
243
        blocks[r->mb_type[mb_pos - s->mb_stride]]++;
244
244
        if(r->avail_cache[6-2])
245
245
            blocks[r->mb_type[mb_pos - s->mb_stride + 1]]++;
246
246
        if(r->avail_cache[6-5])
247
247
            blocks[r->mb_type[mb_pos - s->mb_stride - 1]]++;
248
 
    }
 
248
        for(i = 0; i < RV34_MB_TYPES; i++){
 
249
            if(blocks[i] > count){
 
250
                count = blocks[i];
 
251
                prev_type = i;
 
252
                if(count>1)
 
253
                    break;
 
254
            }
 
255
        }
 
256
    } else if (r->avail_cache[6-1])
 
257
        prev_type = r->mb_type[mb_pos - 1];
249
258
 
250
 
    for(i = 0; i < RV34_MB_TYPES; i++){
251
 
        if(blocks[i] > count){
252
 
            count = blocks[i];
253
 
            prev_type = i;
254
 
        }
255
 
    }
256
259
    if(s->pict_type == AV_PICTURE_TYPE_P){
257
260
        prev_type = block_num_to_ptype_vlc_num[prev_type];
258
261
        q = get_vlc2(gb, ptype_vlc[prev_type].table, PTYPE_VLC_BITS, 1);
357
360
     * in addition to the coded ones because because they lie at the edge of
358
361
     * 8x8 block with different enough motion vectors
359
362
     */
360
 
    int mvmasks[4];
 
363
    unsigned mvmasks[4];
361
364
 
362
365
    mb_pos = row * s->mb_stride;
363
366
    for(mb_x = 0; mb_x < s->mb_width; mb_x++, mb_pos++){
373
376
        int c_v_deblock[2], c_h_deblock[2];
374
377
        int clip_left;
375
378
        int avail[4];
376
 
        int y_to_deblock, c_to_deblock[2];
 
379
        unsigned y_to_deblock;
 
380
        int c_to_deblock[2];
377
381
 
378
382
        q = s->current_picture_ptr->f.qscale_table[mb_pos];
379
383
        alpha = rv40_alpha_tab[q];
427
431
            y_v_deblock &= ~MASK_Y_LEFT_COL;
428
432
        if(!row)
429
433
            y_h_deblock &= ~MASK_Y_TOP_ROW;
430
 
        if(row == s->mb_height - 1 || (mb_strong[POS_CUR] || mb_strong[POS_BOTTOM]))
 
434
        if(row == s->mb_height - 1 || (mb_strong[POS_CUR] | mb_strong[POS_BOTTOM]))
431
435
            y_h_deblock &= ~(MASK_Y_TOP_ROW << 16);
432
436
        /* Calculating chroma patterns is similar and easier since there is
433
437
         * no motion vector pattern for them.
444
448
                c_v_deblock[i] &= ~MASK_C_LEFT_COL;
445
449
            if(!row)
446
450
                c_h_deblock[i] &= ~MASK_C_TOP_ROW;
447
 
            if(row == s->mb_height - 1 || mb_strong[POS_CUR] || mb_strong[POS_BOTTOM])
 
451
            if(row == s->mb_height - 1 || (mb_strong[POS_CUR] | mb_strong[POS_BOTTOM]))
448
452
                c_h_deblock[i] &= ~(MASK_C_TOP_ROW << 4);
449
453
        }
450
454
 
465
469
                                              0, 0, 0);
466
470
                }
467
471
                // filter left block edge in ordinary mode (with low filtering strength)
468
 
                if(y_v_deblock & (MASK_CUR << ij) && (i || !(mb_strong[POS_CUR] || mb_strong[POS_LEFT]))){
 
472
                if(y_v_deblock & (MASK_CUR << ij) && (i || !(mb_strong[POS_CUR] | mb_strong[POS_LEFT]))){
469
473
                    if(!i)
470
474
                        clip_left = mvmasks[POS_LEFT] & (MASK_RIGHT << j) ? clip[POS_LEFT] : 0;
471
475
                    else
476
480
                                              alpha, beta, betaY, 0, 0, 1);
477
481
                }
478
482
                // filter top edge of the current macroblock when filtering strength is high
479
 
                if(!j && y_h_deblock & (MASK_CUR << i) && (mb_strong[POS_CUR] || mb_strong[POS_TOP])){
 
483
                if(!j && y_h_deblock & (MASK_CUR << i) && (mb_strong[POS_CUR] | mb_strong[POS_TOP])){
480
484
                    rv40_adaptive_loop_filter(&r->rdsp, Y, s->linesize, dither,
481
485
                                       clip_cur,
482
486
                                       mvmasks[POS_TOP] & (MASK_TOP << i) ? clip[POS_TOP] : 0,
483
487
                                       alpha, beta, betaY, 0, 1, 0);
484
488
                }
485
489
                // filter left block edge in edge mode (with high filtering strength)
486
 
                if(y_v_deblock & (MASK_CUR << ij) && !i && (mb_strong[POS_CUR] || mb_strong[POS_LEFT])){
 
490
                if(y_v_deblock & (MASK_CUR << ij) && !i && (mb_strong[POS_CUR] | mb_strong[POS_LEFT])){
487
491
                    clip_left = mvmasks[POS_LEFT] & (MASK_RIGHT << j) ? clip[POS_LEFT] : 0;
488
492
                    rv40_adaptive_loop_filter(&r->rdsp, Y, s->linesize, dither,
489
493
                                       clip_cur,
505
509
                                           clip_cur,
506
510
                                           alpha, beta, betaC, 1, 0, 0);
507
511
                    }
508
 
                    if((c_v_deblock[k] & (MASK_CUR << ij)) && (i || !(mb_strong[POS_CUR] || mb_strong[POS_LEFT]))){
 
512
                    if((c_v_deblock[k] & (MASK_CUR << ij)) && (i || !(mb_strong[POS_CUR] | mb_strong[POS_LEFT]))){
509
513
                        if(!i)
510
514
                            clip_left = uvcbp[POS_LEFT][k] & (MASK_CUR << (2*j+1)) ? clip[POS_LEFT] : 0;
511
515
                        else
515
519
                                           clip_left,
516
520
                                           alpha, beta, betaC, 1, 0, 1);
517
521
                    }
518
 
                    if(!j && c_h_deblock[k] & (MASK_CUR << ij) && (mb_strong[POS_CUR] || mb_strong[POS_TOP])){
 
522
                    if(!j && c_h_deblock[k] & (MASK_CUR << ij) && (mb_strong[POS_CUR] | mb_strong[POS_TOP])){
519
523
                        int clip_top = uvcbp[POS_TOP][k] & (MASK_CUR << (ij+2)) ? clip[POS_TOP] : 0;
520
524
                        rv40_adaptive_loop_filter(&r->rdsp, C, s->uvlinesize, i*8,
521
525
                                           clip_cur,
522
526
                                           clip_top,
523
527
                                           alpha, beta, betaC, 1, 1, 0);
524
528
                    }
525
 
                    if(c_v_deblock[k] & (MASK_CUR << ij) && !i && (mb_strong[POS_CUR] || mb_strong[POS_LEFT])){
 
529
                    if(c_v_deblock[k] & (MASK_CUR << ij) && !i && (mb_strong[POS_CUR] | mb_strong[POS_LEFT])){
526
530
                        clip_left = uvcbp[POS_LEFT][k] & (MASK_CUR << (2*j+1)) ? clip[POS_LEFT] : 0;
527
531
                        rv40_adaptive_loop_filter(&r->rdsp, C, s->uvlinesize, j*8,
528
532
                                           clip_cur,
556
560
}
557
561
 
558
562
AVCodec ff_rv40_decoder = {
559
 
    .name           = "rv40",
560
 
    .type           = AVMEDIA_TYPE_VIDEO,
561
 
    .id             = CODEC_ID_RV40,
562
 
    .priv_data_size = sizeof(RV34DecContext),
563
 
    .init           = rv40_decode_init,
564
 
    .close          = ff_rv34_decode_end,
565
 
    .decode         = ff_rv34_decode_frame,
566
 
    .capabilities   = CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_FRAME_THREADS,
567
 
    .flush          = ff_mpeg_flush,
568
 
    .long_name      = NULL_IF_CONFIG_SMALL("RealVideo 4.0"),
569
 
    .pix_fmts       = ff_pixfmt_list_420,
 
563
    .name                  = "rv40",
 
564
    .type                  = AVMEDIA_TYPE_VIDEO,
 
565
    .id                    = AV_CODEC_ID_RV40,
 
566
    .priv_data_size        = sizeof(RV34DecContext),
 
567
    .init                  = rv40_decode_init,
 
568
    .close                 = ff_rv34_decode_end,
 
569
    .decode                = ff_rv34_decode_frame,
 
570
    .capabilities          = CODEC_CAP_DR1 | CODEC_CAP_DELAY |
 
571
                             CODEC_CAP_FRAME_THREADS,
 
572
    .flush                 = ff_mpeg_flush,
 
573
    .long_name             = NULL_IF_CONFIG_SMALL("RealVideo 4.0"),
 
574
    .pix_fmts              = ff_pixfmt_list_420,
570
575
    .init_thread_copy      = ONLY_IF_THREADS_ENABLED(ff_rv34_decode_init_thread_copy),
571
576
    .update_thread_context = ONLY_IF_THREADS_ENABLED(ff_rv34_decode_update_thread_context),
572
577
};