Commit 01bfdbe4 authored by pulento's avatar pulento

- Added support to Inter4V+Q MBs to H.263 decoder.

- Advanced Prediction Mode activated for H.263 decoder.
- Bug fixed on H.263+ header parsing for UFEP.
- Now we can decode VIVO v1 streams :)


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@221 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent a306abc2
...@@ -750,7 +750,7 @@ void h263_decode_init_vlc(MpegEncContext *s) ...@@ -750,7 +750,7 @@ void h263_decode_init_vlc(MpegEncContext *s)
init_vlc(&intra_MCBPC_vlc, 6, 8, init_vlc(&intra_MCBPC_vlc, 6, 8,
intra_MCBPC_bits, 1, 1, intra_MCBPC_bits, 1, 1,
intra_MCBPC_code, 1, 1); intra_MCBPC_code, 1, 1);
init_vlc(&inter_MCBPC_vlc, 9, 20, init_vlc(&inter_MCBPC_vlc, 9, 25,
inter_MCBPC_bits, 1, 1, inter_MCBPC_bits, 1, 1,
inter_MCBPC_code, 1, 1); inter_MCBPC_code, 1, 1);
init_vlc(&cbpy_vlc, 6, 16, init_vlc(&cbpy_vlc, 6, 16,
...@@ -825,6 +825,10 @@ int h263_decode_mb(MpegEncContext *s, ...@@ -825,6 +825,10 @@ int h263_decode_mb(MpegEncContext *s,
//fprintf(stderr, "\tCBPC: %d", cbpc); //fprintf(stderr, "\tCBPC: %d", cbpc);
if (cbpc < 0) if (cbpc < 0)
return -1; return -1;
if (cbpc > 20)
cbpc+=3;
else if (cbpc == 20)
fprintf(stderr, "Stuffing !");
dquant = cbpc & 8; dquant = cbpc & 8;
s->mb_intra = ((cbpc & 4) != 0); s->mb_intra = ((cbpc & 4) != 0);
...@@ -1223,7 +1227,7 @@ int h263_decode_picture_header(MpegEncContext *s) ...@@ -1223,7 +1227,7 @@ int h263_decode_picture_header(MpegEncContext *s)
format = get_bits(&s->gb, 3); format = get_bits(&s->gb, 3);
if (format != 7) { if (format != 7 && format != 6) {
s->h263_plus = 0; s->h263_plus = 0;
/* H.263v1 */ /* H.263v1 */
width = h263_format[format][0]; width = h263_format[format][0];
...@@ -1231,6 +1235,8 @@ int h263_decode_picture_header(MpegEncContext *s) ...@@ -1231,6 +1235,8 @@ int h263_decode_picture_header(MpegEncContext *s)
if (!width) if (!width)
return -1; return -1;
s->width = width;
s->height = height;
s->pict_type = I_TYPE + get_bits1(&s->gb); s->pict_type = I_TYPE + get_bits1(&s->gb);
s->unrestricted_mv = get_bits1(&s->gb); s->unrestricted_mv = get_bits1(&s->gb);
...@@ -1238,26 +1244,35 @@ int h263_decode_picture_header(MpegEncContext *s) ...@@ -1238,26 +1244,35 @@ int h263_decode_picture_header(MpegEncContext *s)
if (get_bits1(&s->gb) != 0) if (get_bits1(&s->gb) != 0)
return -1; /* SAC: off */ return -1; /* SAC: off */
if (get_bits1(&s->gb) != 0) if (get_bits1(&s->gb) != 0) {
return -1; /* advanced prediction mode: off */ s->mv_type = MV_TYPE_8X8; /* Advanced prediction mode */
}
if (get_bits1(&s->gb) != 0) if (get_bits1(&s->gb) != 0)
return -1; /* not PB frame */ return -1; /* not PB frame */
s->qscale = get_bits(&s->gb, 5); s->qscale = get_bits(&s->gb, 5);
skip_bits1(&s->gb); /* Continuous Presence Multipoint mode: off */ skip_bits1(&s->gb); /* Continuous Presence Multipoint mode: off */
} else { } else {
s->h263_plus = 1; int ufep;
/* H.263v2 */ /* H.263v2 */
/* OPPTYPE */ s->h263_plus = 1;
ufep = get_bits(&s->gb, 3); /* Update Full Extended PTYPE */
if (get_bits(&s->gb, 3) != 1) /* Update Full Extended PTYPE */ if (ufep == 1) {
return -1; /* OPPTYPE */
format = get_bits(&s->gb, 3); format = get_bits(&s->gb, 3);
skip_bits(&s->gb,1); /* Custom PCF */ skip_bits(&s->gb,1); /* Custom PCF */
s->umvplus_dec = get_bits(&s->gb, 1); /* Unrestricted Motion Vector */ s->umvplus_dec = get_bits(&s->gb, 1); /* Unrestricted Motion Vector */
skip_bits(&s->gb, 10); skip_bits1(&s->gb); /* Syntax-based Arithmetic Coding (SAC) */
if (get_bits1(&s->gb) != 0) {
s->mv_type = MV_TYPE_8X8; /* Advanced prediction mode */
}
skip_bits(&s->gb, 8);
skip_bits(&s->gb, 3); /* Reserved */ skip_bits(&s->gb, 3); /* Reserved */
} else if (ufep != 0)
return -1;
/* MPPTYPE */ /* MPPTYPE */
s->pict_type = get_bits(&s->gb, 3) + 1; s->pict_type = get_bits(&s->gb, 3) + 1;
...@@ -1267,6 +1282,7 @@ int h263_decode_picture_header(MpegEncContext *s) ...@@ -1267,6 +1282,7 @@ int h263_decode_picture_header(MpegEncContext *s)
skip_bits(&s->gb, 7); skip_bits(&s->gb, 7);
/* Get the picture dimensions */ /* Get the picture dimensions */
if (ufep) {
if (format == 6) { if (format == 6) {
/* Custom Picture Format (CPFMT) */ /* Custom Picture Format (CPFMT) */
skip_bits(&s->gb, 4); /* aspect ratio */ skip_bits(&s->gb, 4); /* aspect ratio */
...@@ -1281,13 +1297,14 @@ int h263_decode_picture_header(MpegEncContext *s) ...@@ -1281,13 +1297,14 @@ int h263_decode_picture_header(MpegEncContext *s)
width = h263_format[format][0]; width = h263_format[format][0];
height = h263_format[format][1]; height = h263_format[format][1];
} }
if ((width == 0) || (height == 0)) if ((width == 0) || (height == 0))
return -1; return -1;
s->width = width;
s->height = height;
if (s->umvplus_dec) { if (s->umvplus_dec) {
skip_bits1(&s->gb); /* Unlimited Unrestricted Motion Vectors Indicator (UUI) */ skip_bits1(&s->gb); /* Unlimited Unrestricted Motion Vectors Indicator (UUI) */
} }
}
s->qscale = get_bits(&s->gb, 5); s->qscale = get_bits(&s->gb, 5);
} }
...@@ -1296,9 +1313,6 @@ int h263_decode_picture_header(MpegEncContext *s) ...@@ -1296,9 +1313,6 @@ int h263_decode_picture_header(MpegEncContext *s)
skip_bits(&s->gb, 8); skip_bits(&s->gb, 8);
} }
s->f_code = 1; s->f_code = 1;
s->width = width;
s->height = height;
return 0; return 0;
} }
......
...@@ -4,20 +4,24 @@ static const UINT8 intra_MCBPC_code[8] = { 1, 1, 2, 3, 1, 1, 2, 3 }; ...@@ -4,20 +4,24 @@ static const UINT8 intra_MCBPC_code[8] = { 1, 1, 2, 3, 1, 1, 2, 3 };
static const UINT8 intra_MCBPC_bits[8] = { 1, 3, 3, 3, 4, 6, 6, 6 }; static const UINT8 intra_MCBPC_bits[8] = { 1, 3, 3, 3, 4, 6, 6, 6 };
/* inter MCBPC, mb_type = (inter), (intra), (interq), (intraq), (inter4v) */ /* inter MCBPC, mb_type = (inter), (intra), (interq), (intraq), (inter4v) */
/* Changed the tables for interq, following the standard ** Juanjo ** */ /* Changed the tables for interq and inter4v+q, following the standard ** Juanjo ** */
static const UINT8 inter_MCBPC_code[20] = { static const UINT8 inter_MCBPC_code[25] = {
1, 3, 2, 5, 1, 3, 2, 5,
3, 4, 3, 3, 3, 4, 3, 3,
3, 7, 6, 5, 3, 7, 6, 5,
4, 4, 3, 2, 4, 4, 3, 2,
2, 5, 4, 5, 2, 5, 4, 5,
1, /* Stuffing */
2, 12, 14, 15,
}; };
static const UINT8 inter_MCBPC_bits[20] = { static const UINT8 inter_MCBPC_bits[25] = {
1, 4, 4, 6, 1, 4, 4, 6,
5, 8, 8, 7, 5, 8, 8, 7,
3, 7, 7, 9, 3, 7, 7, 9,
6, 9, 9, 9, 6, 9, 9, 9,
3, 7, 7, 8, 3, 7, 7, 8,
9, /* Stuffing */
11, 13, 13, 13,
}; };
/* This is the old table /* This is the old table
......
...@@ -163,9 +163,11 @@ static int h263_decode_frame(AVCodecContext *avctx, ...@@ -163,9 +163,11 @@ static int h263_decode_frame(AVCodecContext *avctx,
if (msmpeg4_decode_mb(s, s->block) < 0) if (msmpeg4_decode_mb(s, s->block) < 0)
return -1; return -1;
} else { } else {
if (h263_decode_mb(s, s->block) < 0) if (h263_decode_mb(s, s->block) < 0) {
fprintf(stderr,"\nError at MB: %d\n", (s->mb_y * s->mb_width) + s->mb_x);
return -1; return -1;
} }
}
MPV_decode_mb(s, s->block); MPV_decode_mb(s, s->block);
} }
if (avctx->draw_horiz_band) { if (avctx->draw_horiz_band) {
......
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