Revision ceb48b46 libavcodec/cavs.c

View differences:

libavcodec/cavs.c
71 71
 * ---------
72 72
 *
73 73
 */
74
static void filter_mb(AVSContext *h, enum mb_t mb_type) {
74
void ff_cavs_filter(AVSContext *h, enum mb_t mb_type) {
75 75
    DECLARE_ALIGNED_8(uint8_t, bs[8]);
76 76
    int qp_avg, alpha, beta, tc;
77 77
    int i;
......
323 323
    }
324 324
}
325 325

  
326
static void inter_pred(AVSContext *h, enum mb_t mb_type) {
326
void ff_cavs_inter(AVSContext *h, enum mb_t mb_type) {
327 327
    if(partition_flags[mb_type] == 0){ // 16x16
328 328
        mc_part_std(h, 1, 8, 0, h->cy, h->cu, h->cv, 0, 0,
329 329
                h->s.dsp.put_cavs_qpel_pixels_tab[0],
......
428 428
    set_mvs(dst, size);
429 429
}
430 430

  
431
static void mv_pred(AVSContext *h, enum mv_loc_t nP, enum mv_loc_t nC,
432
                    enum mv_pred_t mode, enum block_t size, int ref) {
431
void ff_cavs_mv(AVSContext *h, enum mv_loc_t nP, enum mv_loc_t nC,
432
                enum mv_pred_t mode, enum block_t size, int ref) {
433 433
    vector_t *mvP = &h->mv[nP];
434 434
    vector_t *mvA = &h->mv[nP-1];
435 435
    vector_t *mvB = &h->mv[nP-4];
......
631 631
                                  h->left_border_v, h->c_stride);
632 632

  
633 633
    decode_residual_chroma(h);
634
    filter_mb(h,I_8X8);
634
    ff_cavs_filter(h,I_8X8);
635 635
    set_mv_intra(h);
636 636
    return 0;
637 637
}
......
643 643
    init_mb(h);
644 644
    switch(mb_type) {
645 645
    case P_SKIP:
646
        mv_pred(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_PSKIP, BLK_16X16, 0);
646
        ff_cavs_mv(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_PSKIP,  BLK_16X16, 0);
647 647
        break;
648 648
    case P_16X16:
649 649
        ref[0] = h->ref_flag ? 0 : get_bits1(gb);
650
        mv_pred(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_MEDIAN,   BLK_16X16,ref[0]);
650
        ff_cavs_mv(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_MEDIAN, BLK_16X16,ref[0]);
651 651
        break;
652 652
    case P_16X8:
653 653
        ref[0] = h->ref_flag ? 0 : get_bits1(gb);
654 654
        ref[2] = h->ref_flag ? 0 : get_bits1(gb);
655
        mv_pred(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_TOP,      BLK_16X8, ref[0]);
656
        mv_pred(h, MV_FWD_X2, MV_FWD_A1, MV_PRED_LEFT,     BLK_16X8, ref[2]);
655
        ff_cavs_mv(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_TOP,    BLK_16X8, ref[0]);
656
        ff_cavs_mv(h, MV_FWD_X2, MV_FWD_A1, MV_PRED_LEFT,   BLK_16X8, ref[2]);
657 657
        break;
658 658
    case P_8X16:
659 659
        ref[0] = h->ref_flag ? 0 : get_bits1(gb);
660 660
        ref[1] = h->ref_flag ? 0 : get_bits1(gb);
661
        mv_pred(h, MV_FWD_X0, MV_FWD_B3, MV_PRED_LEFT,     BLK_8X16, ref[0]);
662
        mv_pred(h, MV_FWD_X1, MV_FWD_C2, MV_PRED_TOPRIGHT, BLK_8X16, ref[1]);
661
        ff_cavs_mv(h, MV_FWD_X0, MV_FWD_B3, MV_PRED_LEFT,   BLK_8X16, ref[0]);
662
        ff_cavs_mv(h, MV_FWD_X1, MV_FWD_C2, MV_PRED_TOPRIGHT,BLK_8X16, ref[1]);
663 663
        break;
664 664
    case P_8X8:
665 665
        ref[0] = h->ref_flag ? 0 : get_bits1(gb);
666 666
        ref[1] = h->ref_flag ? 0 : get_bits1(gb);
667 667
        ref[2] = h->ref_flag ? 0 : get_bits1(gb);
668 668
        ref[3] = h->ref_flag ? 0 : get_bits1(gb);
669
        mv_pred(h, MV_FWD_X0, MV_FWD_B3, MV_PRED_MEDIAN,   BLK_8X8, ref[0]);
670
        mv_pred(h, MV_FWD_X1, MV_FWD_C2, MV_PRED_MEDIAN,   BLK_8X8, ref[1]);
671
        mv_pred(h, MV_FWD_X2, MV_FWD_X1, MV_PRED_MEDIAN,   BLK_8X8, ref[2]);
672
        mv_pred(h, MV_FWD_X3, MV_FWD_X0, MV_PRED_MEDIAN,   BLK_8X8, ref[3]);
669
        ff_cavs_mv(h, MV_FWD_X0, MV_FWD_B3, MV_PRED_MEDIAN,   BLK_8X8, ref[0]);
670
        ff_cavs_mv(h, MV_FWD_X1, MV_FWD_C2, MV_PRED_MEDIAN,   BLK_8X8, ref[1]);
671
        ff_cavs_mv(h, MV_FWD_X2, MV_FWD_X1, MV_PRED_MEDIAN,   BLK_8X8, ref[2]);
672
        ff_cavs_mv(h, MV_FWD_X3, MV_FWD_X0, MV_PRED_MEDIAN,   BLK_8X8, ref[3]);
673 673
    }
674
    inter_pred(h, mb_type);
674
    ff_cavs_inter(h, mb_type);
675 675
    set_intra_mode_default(h);
676 676
    store_mvs(h);
677 677
    if(mb_type != P_SKIP)
678 678
        decode_residual_inter(h);
679
    filter_mb(h,mb_type);
679
    ff_cavs_filter(h,mb_type);
680 680
    *h->col_type = mb_type;
681 681
}
682 682

  
......
697 697
    case B_DIRECT:
698 698
        if(!(*h->col_type)) {
699 699
            /* intra MB at co-location, do in-plane prediction */
700
            mv_pred(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_BSKIP, BLK_16X16, 1);
701
            mv_pred(h, MV_BWD_X0, MV_BWD_C2, MV_PRED_BSKIP, BLK_16X16, 0);
700
            ff_cavs_mv(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_BSKIP, BLK_16X16, 1);
701
            ff_cavs_mv(h, MV_BWD_X0, MV_BWD_C2, MV_PRED_BSKIP, BLK_16X16, 0);
702 702
        } else
703 703
            /* direct prediction from co-located P MB, block-wise */
704 704
            for(block=0;block<4;block++)
......
706 706
                            &h->col_mv[(h->mby*h->mb_width+h->mbx)*4 + block]);
707 707
        break;
708 708
    case B_FWD_16X16:
709
        mv_pred(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_MEDIAN, BLK_16X16, 1);
709
        ff_cavs_mv(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_MEDIAN, BLK_16X16, 1);
710 710
        break;
711 711
    case B_SYM_16X16:
712
        mv_pred(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_MEDIAN, BLK_16X16, 1);
712
        ff_cavs_mv(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_MEDIAN, BLK_16X16, 1);
713 713
        mv_pred_sym(h, &h->mv[MV_FWD_X0], BLK_16X16);
714 714
        break;
715 715
    case B_BWD_16X16:
716
        mv_pred(h, MV_BWD_X0, MV_BWD_C2, MV_PRED_MEDIAN, BLK_16X16, 0);
716
        ff_cavs_mv(h, MV_BWD_X0, MV_BWD_C2, MV_PRED_MEDIAN, BLK_16X16, 0);
717 717
        break;
718 718
    case B_8X8:
719 719
        for(block=0;block<4;block++)
......
723 723
            case B_SUB_DIRECT:
724 724
                if(!(*h->col_type)) {
725 725
                    /* intra MB at co-location, do in-plane prediction */
726
                    mv_pred(h, mv_scan[block], mv_scan[block]-3,
726
                    ff_cavs_mv(h, mv_scan[block], mv_scan[block]-3,
727 727
                            MV_PRED_BSKIP, BLK_8X8, 1);
728
                    mv_pred(h, mv_scan[block]+MV_BWD_OFFS,
728
                    ff_cavs_mv(h, mv_scan[block]+MV_BWD_OFFS,
729 729
                            mv_scan[block]-3+MV_BWD_OFFS,
730 730
                            MV_PRED_BSKIP, BLK_8X8, 0);
731 731
                } else
......
733 733
                                   &h->col_mv[(h->mby*h->mb_width + h->mbx)*4 + block]);
734 734
                break;
735 735
            case B_SUB_FWD:
736
                mv_pred(h, mv_scan[block], mv_scan[block]-3,
736
                ff_cavs_mv(h, mv_scan[block], mv_scan[block]-3,
737 737
                        MV_PRED_MEDIAN, BLK_8X8, 1);
738 738
                break;
739 739
            case B_SUB_SYM:
740
                mv_pred(h, mv_scan[block], mv_scan[block]-3,
740
                ff_cavs_mv(h, mv_scan[block], mv_scan[block]-3,
741 741
                        MV_PRED_MEDIAN, BLK_8X8, 1);
742 742
                mv_pred_sym(h, &h->mv[mv_scan[block]], BLK_8X8);
743 743
                break;
......
745 745
        }
746 746
        for(block=0;block<4;block++) {
747 747
            if(sub_type[block] == B_SUB_BWD)
748
                mv_pred(h, mv_scan[block]+MV_BWD_OFFS,
748
                ff_cavs_mv(h, mv_scan[block]+MV_BWD_OFFS,
749 749
                        mv_scan[block]+MV_BWD_OFFS-3,
750 750
                        MV_PRED_MEDIAN, BLK_8X8, 0);
751 751
        }
......
755 755
        flags = partition_flags[mb_type];
756 756
        if(mb_type & 1) { /* 16x8 macroblock types */
757 757
            if(flags & FWD0)
758
                mv_pred(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_TOP,  BLK_16X8, 1);
758
                ff_cavs_mv(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_TOP,  BLK_16X8, 1);
759 759
            if(flags & SYM0)
760 760
                mv_pred_sym(h, &h->mv[MV_FWD_X0], BLK_16X8);
761 761
            if(flags & FWD1)
762
                mv_pred(h, MV_FWD_X2, MV_FWD_A1, MV_PRED_LEFT, BLK_16X8, 1);
762
                ff_cavs_mv(h, MV_FWD_X2, MV_FWD_A1, MV_PRED_LEFT, BLK_16X8, 1);
763 763
            if(flags & SYM1)
764 764
                mv_pred_sym(h, &h->mv[MV_FWD_X2], BLK_16X8);
765 765
            if(flags & BWD0)
766
                mv_pred(h, MV_BWD_X0, MV_BWD_C2, MV_PRED_TOP,  BLK_16X8, 0);
766
                ff_cavs_mv(h, MV_BWD_X0, MV_BWD_C2, MV_PRED_TOP,  BLK_16X8, 0);
767 767
            if(flags & BWD1)
768
                mv_pred(h, MV_BWD_X2, MV_BWD_A1, MV_PRED_LEFT, BLK_16X8, 0);
768
                ff_cavs_mv(h, MV_BWD_X2, MV_BWD_A1, MV_PRED_LEFT, BLK_16X8, 0);
769 769
        } else {          /* 8x16 macroblock types */
770 770
            if(flags & FWD0)
771
                mv_pred(h, MV_FWD_X0, MV_FWD_B3, MV_PRED_LEFT, BLK_8X16, 1);
771
                ff_cavs_mv(h, MV_FWD_X0, MV_FWD_B3, MV_PRED_LEFT, BLK_8X16, 1);
772 772
            if(flags & SYM0)
773 773
                mv_pred_sym(h, &h->mv[MV_FWD_X0], BLK_8X16);
774 774
            if(flags & FWD1)
775
                mv_pred(h, MV_FWD_X1, MV_FWD_C2, MV_PRED_TOPRIGHT,BLK_8X16, 1);
775
                ff_cavs_mv(h,MV_FWD_X1,MV_FWD_C2,MV_PRED_TOPRIGHT,BLK_8X16,1);
776 776
            if(flags & SYM1)
777 777
                mv_pred_sym(h, &h->mv[MV_FWD_X1], BLK_8X16);
778 778
            if(flags & BWD0)
779
                mv_pred(h, MV_BWD_X0, MV_BWD_B3, MV_PRED_LEFT, BLK_8X16, 0);
779
                ff_cavs_mv(h, MV_BWD_X0, MV_BWD_B3, MV_PRED_LEFT, BLK_8X16, 0);
780 780
            if(flags & BWD1)
781
                mv_pred(h, MV_BWD_X1, MV_BWD_C2, MV_PRED_TOPRIGHT,BLK_8X16, 0);
781
                ff_cavs_mv(h,MV_BWD_X1,MV_BWD_C2,MV_PRED_TOPRIGHT,BLK_8X16,0);
782 782
        }
783 783
    }
784
    inter_pred(h, mb_type);
784
    ff_cavs_inter(h, mb_type);
785 785
    set_intra_mode_default(h);
786 786
    if(mb_type != B_SKIP)
787 787
        decode_residual_inter(h);
788
    filter_mb(h,mb_type);
788
    ff_cavs_filter(h,mb_type);
789 789
}
790 790

  
791 791
/*****************************************************************************
......
828 828
 *
829 829
 ****************************************************************************/
830 830

  
831
static void init_pic(AVSContext *h) {
831
void ff_cavs_init_pic(AVSContext *h) {
832 832
    int i;
833 833

  
834 834
    /* clear some predictors */
......
882 882
        s->avctx->release_buffer(s->avctx, (AVFrame *)&h->picture);
883 883

  
884 884
    s->avctx->get_buffer(s->avctx, (AVFrame *)&h->picture);
885
    init_pic(h);
885
    ff_cavs_init_pic(h);
886 886
    h->picture.poc = get_bits(&s->gb,8)*2;
887 887

  
888 888
    /* get temporal distances and MV scaling factors */
......
991 991
 * this data has to be stored for one complete row of macroblocks
992 992
 * and this storage space is allocated here
993 993
 */
994
static void init_top_lines(AVSContext *h) {
994
void ff_cavs_init_top_lines(AVSContext *h) {
995 995
    /* alloc top line of predictors */
996 996
    h->top_qp       = av_malloc( h->mb_width);
997 997
    h->top_mv[0]    = av_malloc((h->mb_width*2+1)*sizeof(vector_t));
......
1031 1031
    h->s.avctx->width  = s->width;
1032 1032
    h->s.avctx->height = s->height;
1033 1033
    if(!h->top_qp)
1034
        init_top_lines(h);
1034
        ff_cavs_init_top_lines(h);
1035 1035
    return 0;
1036 1036
}
1037 1037

  
......
1115 1115
    }
1116 1116
}
1117 1117

  
1118
static int cavs_decode_init(AVCodecContext * avctx) {
1118
int ff_cavs_init(AVCodecContext *avctx) {
1119 1119
    AVSContext *h = avctx->priv_data;
1120 1120
    MpegEncContext * const s = &h->s;
1121 1121

  
......
1146 1146
    return 0;
1147 1147
}
1148 1148

  
1149
static int cavs_decode_end(AVCodecContext * avctx) {
1149
int ff_cavs_end(AVCodecContext *avctx) {
1150 1150
    AVSContext *h = avctx->priv_data;
1151 1151

  
1152 1152
    av_free(h->top_qp);
......
1167 1167
    CODEC_TYPE_VIDEO,
1168 1168
    CODEC_ID_CAVS,
1169 1169
    sizeof(AVSContext),
1170
    cavs_decode_init,
1170
    ff_cavs_init,
1171 1171
    NULL,
1172
    cavs_decode_end,
1172
    ff_cavs_end,
1173 1173
    cavs_decode_frame,
1174 1174
    CODEC_CAP_DR1 | CODEC_CAP_DELAY,
1175 1175
    .flush= cavs_flush,

Also available in: Unified diff