Commit 388b4cf8 authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/vc1: factor read_bfraction() out

Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent f4b288a6
...@@ -613,6 +613,12 @@ static void rotate_luts(VC1Context *v) ...@@ -613,6 +613,12 @@ static void rotate_luts(VC1Context *v)
*v->curr_use_ic = 0; *v->curr_use_ic = 0;
} }
static int read_bfraction(VC1Context *v, GetBitContext* gb) {
v->bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1);
v->bfraction = ff_vc1_bfraction_lut[v->bfraction_lut_index];
return 0;
}
int ff_vc1_parse_frame_header(VC1Context *v, GetBitContext* gb) int ff_vc1_parse_frame_header(VC1Context *v, GetBitContext* gb)
{ {
int pqindex, lowquant, status; int pqindex, lowquant, status;
...@@ -644,8 +650,8 @@ int ff_vc1_parse_frame_header(VC1Context *v, GetBitContext* gb) ...@@ -644,8 +650,8 @@ int ff_vc1_parse_frame_header(VC1Context *v, GetBitContext* gb)
v->bi_type = 0; v->bi_type = 0;
if (v->s.pict_type == AV_PICTURE_TYPE_B) { if (v->s.pict_type == AV_PICTURE_TYPE_B) {
v->bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1); if (read_bfraction(v, gb) < 0)
v->bfraction = ff_vc1_bfraction_lut[v->bfraction_lut_index]; return AVERROR_INVALIDDATA;
if (v->bfraction == 0) { if (v->bfraction == 0) {
v->s.pict_type = AV_PICTURE_TYPE_BI; v->s.pict_type = AV_PICTURE_TYPE_BI;
} }
...@@ -928,8 +934,8 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) ...@@ -928,8 +934,8 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
v->refdist += get_unary(gb, 0, 16); v->refdist += get_unary(gb, 0, 16);
} }
if ((v->s.pict_type == AV_PICTURE_TYPE_B) || (v->s.pict_type == AV_PICTURE_TYPE_BI)) { if ((v->s.pict_type == AV_PICTURE_TYPE_B) || (v->s.pict_type == AV_PICTURE_TYPE_BI)) {
v->bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1); if (read_bfraction(v, gb) < 0)
v->bfraction = ff_vc1_bfraction_lut[v->bfraction_lut_index]; return AVERROR_INVALIDDATA;
v->frfd = (v->bfraction * v->refdist) >> 8; v->frfd = (v->bfraction * v->refdist) >> 8;
v->brfd = v->refdist - v->frfd - 1; v->brfd = v->refdist - v->frfd - 1;
if (v->brfd < 0) if (v->brfd < 0)
...@@ -941,8 +947,8 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) ...@@ -941,8 +947,8 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
if (v->finterpflag) if (v->finterpflag)
v->interpfrm = get_bits1(gb); v->interpfrm = get_bits1(gb);
if (v->s.pict_type == AV_PICTURE_TYPE_B) { if (v->s.pict_type == AV_PICTURE_TYPE_B) {
v->bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1); if (read_bfraction(v, gb) < 0)
v->bfraction = ff_vc1_bfraction_lut[v->bfraction_lut_index]; return AVERROR_INVALIDDATA;
if (v->bfraction == 0) { if (v->bfraction == 0) {
v->s.pict_type = AV_PICTURE_TYPE_BI; /* XXX: should not happen here */ v->s.pict_type = AV_PICTURE_TYPE_BI; /* XXX: should not happen here */
} }
...@@ -1186,8 +1192,8 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) ...@@ -1186,8 +1192,8 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
break; break;
case AV_PICTURE_TYPE_B: case AV_PICTURE_TYPE_B:
if (v->fcm == ILACE_FRAME) { if (v->fcm == ILACE_FRAME) {
v->bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1); if (read_bfraction(v, gb) < 0)
v->bfraction = ff_vc1_bfraction_lut[v->bfraction_lut_index]; return AVERROR_INVALIDDATA;
if (v->bfraction == 0) { if (v->bfraction == 0) {
return -1; return -1;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment