Revision 685502cf

View differences:

libavcodec/h263.c
40 40
#include "h263data.h"
41 41
#include "mpeg4data.h"
42 42
#include "mathops.h"
43
#include "unary.h"
43 44

  
44 45
//#undef NDEBUG
45 46
//#include <assert.h>
......
3905 3906
    ff_set_qscale(s, s->qscale);
3906 3907
}
3907 3908

  
3909
static int h263_skip_b_part(MpegEncContext *s, int cbp)
3910
{
3911
    DECLARE_ALIGNED(16, DCTELEM, dblock[64]);
3912
    int i, mbi;
3913

  
3914
    /* we have to set s->mb_intra to zero to decode B-part of PB-frame correctly
3915
     * but real value should be restored in order to be used later (in OBMC condition)
3916
     */
3917
    mbi = s->mb_intra;
3918
    s->mb_intra = 0;
3919
    for (i = 0; i < 6; i++) {
3920
        if (h263_decode_block(s, dblock, i, cbp&32) < 0)
3921
            return -1;
3922
        cbp+=cbp;
3923
    }
3924
    s->mb_intra = mbi;
3925
    return 0;
3926
}
3927

  
3928
static int h263_get_modb(GetBitContext *gb, int pb_frame, int *cbpb)
3929
{
3930
    int c, mv = 1;
3931

  
3932
    if (pb_frame < 3) { // h.263 Annex G and i263 PB-frame
3933
        c = get_bits1(gb);
3934
        if (pb_frame == 2 && c)
3935
            mv = !get_bits1(gb);
3936
    } else { // h.263 Annex M improved PB-frame
3937
        mv = get_unary(gb, 0, 4) + 1;
3938
        c = mv & 1;
3939
        mv = !!(mv & 2);
3940
    }
3941
    if(c)
3942
        *cbpb = get_bits(gb, 6);
3943
    return mv;
3944
}
3945

  
3908 3946
int ff_h263_decode_mb(MpegEncContext *s,
3909 3947
                      DCTELEM block[6][64])
3910 3948
{
3911 3949
    int cbpc, cbpy, i, cbp, pred_x, pred_y, mx, my, dquant;
3912 3950
    int16_t *mot_val;
3913 3951
    const int xy= s->mb_x + s->mb_y * s->mb_stride;
3952
    int cbpb = 0, pb_mv_count = 0;
3914 3953

  
3915 3954
    assert(!s->h263_pred);
3916 3955

  
......
3943 3982
        s->mb_intra = ((cbpc & 4) != 0);
3944 3983
        if (s->mb_intra) goto intra;
3945 3984

  
3985
        if(s->pb_frame && get_bits1(&s->gb))
3986
            pb_mv_count = h263_get_modb(&s->gb, s->pb_frame, &cbpb);
3946 3987
        cbpy = get_vlc2(&s->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1);
3947 3988

  
3948 3989
        if(s->alt_inter_vlc==0 || (cbpc & 3)!=3)
......
4118 4159
        }else
4119 4160
            s->ac_pred = 0;
4120 4161

  
4162
        if(s->pb_frame && get_bits1(&s->gb))
4163
            pb_mv_count = h263_get_modb(&s->gb, s->pb_frame, &cbpb);
4121 4164
        cbpy = get_vlc2(&s->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1);
4122 4165
        if(cbpy<0){
4123 4166
            av_log(s->avctx, AV_LOG_ERROR, "I cbpy damaged at %d %d\n", s->mb_x, s->mb_y);
......
4127 4170
        if (dquant) {
4128 4171
            h263_decode_dquant(s);
4129 4172
        }
4173

  
4174
        pb_mv_count += !!s->pb_frame;
4175
    }
4176

  
4177
    while(pb_mv_count--){
4178
        h263_decode_motion(s, 0, 1);
4179
        h263_decode_motion(s, 0, 1);
4130 4180
    }
4131 4181

  
4132 4182
    /* decode each block */
......
4136 4186
        cbp+=cbp;
4137 4187
    }
4138 4188

  
4189
    if(s->pb_frame && h263_skip_b_part(s, cbpb) < 0)
4190
        return -1;
4139 4191
    if(s->obmc && !s->mb_intra){
4140 4192
        if(s->pict_type == FF_P_TYPE && s->mb_x+1<s->mb_width && s->mb_num_left != 1)
4141 4193
            preview_obmc(s);
......
6241 6293
    if(s->avctx->debug&FF_DEBUG_PICT_INFO)
6242 6294
        show_pict_info(s);
6243 6295

  
6244
    if(s->pb_frame){
6245
        av_log(s->avctx, AV_LOG_ERROR, "PB frame mode no supported\n");
6246
        return -1;      /* PB frame mode */
6247
    }
6248 6296
    return 0;
6249 6297
}
6250 6298

  

Also available in: Unified diff