Revision ad78c0f3

View differences:

libavcodec/cavs.c
574 574
}
575 575

  
576 576
static inline void mv_pred_direct(AVSContext *h, vector_t *pmv_fw,
577
                                  vector_t *pmv_bw, vector_t *col_mv) {
577
                                  vector_t *col_mv) {
578
    vector_t *pmv_bw = pmv_fw + MV_BWD_OFFS;
578 579
    int den = h->direct_den[col_mv->ref];
579 580
    int m = col_mv->x >> 31;
580 581

  
......
862 863
    return 1;
863 864
}
864 865

  
865
static void decode_mb_i(AVSContext *h, int is_i_pic) {
866
static void decode_mb_i(AVSContext *h) {
866 867
    GetBitContext *gb = &h->s.gb;
867 868
    int block, pred_mode_uv;
868 869
    uint8_t top[18];
869 870
    uint8_t left[18];
870 871
    uint8_t *d;
871 872

  
873
    init_mb(h);
874

  
872 875
    /* get intra prediction modes from stream */
873 876
    for(block=0;block<4;block++) {
874 877
        int nA,nB,predpred;
......
913 916
    }
914 917

  
915 918
    /* get coded block pattern */
916
    if(is_i_pic)
919
    if(h->pic_type == FF_I_TYPE)
917 920
        h->cbp = cbp_tab[get_ue_golomb(gb)][0];
918 921
    if(h->cbp && !h->qp_fixed)
919 922
        h->qp += get_se_golomb(gb); //qp_delta
......
960 963
        *h->col_type = I_8X8;
961 964
}
962 965

  
963
static void mb_skip_p(AVSContext *h) {
964
    mv_pred(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_PSKIP, BLK_16X16, 0);
965
    inter_pred(h);
966
    store_mvs(h);
967
    filter_mb(h,P_SKIP);
968
    *h->col_type = P_SKIP;
969
}
970

  
971

  
972
static void mb_skip_b(AVSContext *h) {
973
    int i;
974

  
975
    if(!(*h->col_type)) {
976
        /* intra MB at co-location, do in-plane prediction */
977
        mv_pred(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_BSKIP, BLK_16X16, 1);
978
        mv_pred(h, MV_BWD_X0, MV_BWD_C2, MV_PRED_BSKIP, BLK_16X16, 0);
979
    } else {
980
        /* direct prediction from co-located P MB, block-wise */
981
        for(i=0;i<4;i++)
982
            mv_pred_direct(h,&h->mv[mv_scan[i]],
983
                           &h->mv[mv_scan[i]+MV_BWD_OFFS],
984
                           &h->col_mv[(h->mby*h->mb_width + h->mbx)*4 + i]);
985
    }
986
}
987

  
988 966
static void decode_mb_p(AVSContext *h, enum mb_t mb_type) {
989 967
    GetBitContext *gb = &h->s.gb;
990 968
    int ref[4];
991 969

  
970
    init_mb(h);
992 971
    switch(mb_type) {
993 972
    case P_SKIP:
994
        mb_skip_p(h);
995
        return;
973
        mv_pred(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_PSKIP, BLK_16X16, 0);
974
        break;
996 975
    case P_16X16:
997 976
        ref[0] = h->ref_flag ? 0 : get_bits1(gb);
998 977
        mv_pred(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_MEDIAN,   BLK_16X16,ref[0]);
......
1021 1000
    }
1022 1001
    inter_pred(h);
1023 1002
    store_mvs(h);
1024
    decode_residual_inter(h);
1003
    if(mb_type != P_SKIP)
1004
        decode_residual_inter(h);
1025 1005
    filter_mb(h,mb_type);
1026 1006
    *h->col_type = mb_type;
1027 1007
}
......
1031 1011
    enum sub_mb_t sub_type[4];
1032 1012
    int flags;
1033 1013

  
1014
    init_mb(h);
1015

  
1034 1016
    /* reset all MVs */
1035 1017
    h->mv[MV_FWD_X0] = dir_mv;
1036 1018
    set_mvs(&h->mv[MV_FWD_X0], BLK_16X16);
......
1038 1020
    set_mvs(&h->mv[MV_BWD_X0], BLK_16X16);
1039 1021
    switch(mb_type) {
1040 1022
    case B_SKIP:
1041
        mb_skip_b(h);
1042
        inter_pred(h);
1043
        filter_mb(h,B_SKIP);
1044
        return;
1045 1023
    case B_DIRECT:
1046
        mb_skip_b(h);
1024
        if(!(*h->col_type)) {
1025
            /* intra MB at co-location, do in-plane prediction */
1026
            mv_pred(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_BSKIP, BLK_16X16, 1);
1027
            mv_pred(h, MV_BWD_X0, MV_BWD_C2, MV_PRED_BSKIP, BLK_16X16, 0);
1028
        } else
1029
            /* direct prediction from co-located P MB, block-wise */
1030
            for(block=0;block<4;block++)
1031
                mv_pred_direct(h,&h->mv[mv_scan[block]],
1032
                            &h->col_mv[(h->mby*h->mb_width+h->mbx)*4 + block]);
1047 1033
        break;
1048 1034
    case B_FWD_16X16:
1049 1035
        mv_pred(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_MEDIAN, BLK_16X16, 1);
......
1070 1056
                            MV_PRED_BSKIP, BLK_8X8, 0);
1071 1057
                } else
1072 1058
                    mv_pred_direct(h,&h->mv[mv_scan[block]],
1073
                                   &h->mv[mv_scan[block]+MV_BWD_OFFS],
1074 1059
                                   &h->col_mv[(h->mby*h->mb_width + h->mbx)*4 + block]);
1075 1060
                break;
1076 1061
            case B_SUB_FWD:
......
1131 1116
        }
1132 1117
    }
1133 1118
    inter_pred(h);
1134
    decode_residual_inter(h);
1119
    if(mb_type != B_SKIP)
1120
        decode_residual_inter(h);
1135 1121
    filter_mb(h,mb_type);
1136 1122
}
1137 1123

  
......
1199 1185

  
1200 1186
static int decode_pic(AVSContext *h) {
1201 1187
    MpegEncContext *s = &h->s;
1202
    int i,skip_count;
1188
    int skip_count;
1203 1189
    enum mb_t mb_type;
1204 1190

  
1205 1191
    if (!s->context_initialized) {
......
1273 1259
    check_for_slice(h);
1274 1260
    if(h->pic_type == FF_I_TYPE) {
1275 1261
        do {
1276
            init_mb(h);
1277
            decode_mb_i(h,1);
1262
            decode_mb_i(h);
1278 1263
        } while(next_mb(h));
1279 1264
    } else if(h->pic_type == FF_P_TYPE) {
1280 1265
        do {
1281 1266
            if(h->skip_mode_flag) {
1282 1267
                skip_count = get_ue_golomb(&s->gb);
1283
                for(i=0;i<skip_count;i++) {
1284
                    init_mb(h);
1285
                    mb_skip_p(h);
1268
                while(skip_count--) {
1269
                    decode_mb_p(h,P_SKIP);
1286 1270
                    if(!next_mb(h))
1287 1271
                        goto done;
1288 1272
                }
1289 1273
                mb_type = get_ue_golomb(&s->gb) + P_16X16;
1290 1274
            } else
1291 1275
                mb_type = get_ue_golomb(&s->gb) + P_SKIP;
1292
            init_mb(h);
1293 1276
            if(mb_type > P_8X8) {
1294 1277
                h->cbp = cbp_tab[mb_type - P_8X8 - 1][0];
1295
                decode_mb_i(h,0);
1278
                decode_mb_i(h);
1296 1279
            } else
1297 1280
                decode_mb_p(h,mb_type);
1298 1281
        } while(next_mb(h));
......
1300 1283
        do {
1301 1284
            if(h->skip_mode_flag) {
1302 1285
                skip_count = get_ue_golomb(&s->gb);
1303
                for(i=0;i<skip_count;i++) {
1304
                    init_mb(h);
1305
                    mb_skip_b(h);
1306
                    inter_pred(h);
1307
                    filter_mb(h,B_SKIP);
1286
                while(skip_count--) {
1287
                    decode_mb_b(h,B_SKIP);
1308 1288
                    if(!next_mb(h))
1309 1289
                        goto done;
1310 1290
                }
......
1314 1294
            init_mb(h);
1315 1295
            if(mb_type > B_8X8) {
1316 1296
                h->cbp = cbp_tab[mb_type - B_8X8 - 1][0];
1317
                decode_mb_i(h,0);
1297
                decode_mb_i(h);
1318 1298
            } else
1319 1299
                decode_mb_b(h,mb_type);
1320 1300
        } while(next_mb(h));

Also available in: Unified diff