- Fixed a bug on H.263 MV prediction for MB on GOBs limits.

- Now we can decode H.263v1 streams found on QT without problems.

Originally committed as revision 214 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Juanjo 2001-11-12 05:19:55 +00:00
parent ed8c06708e
commit 102d39088b
3 changed files with 25 additions and 11 deletions

View File

@ -252,7 +252,7 @@ INT16 *h263_pred_motion(MpegEncContext * s, int block,
mot_val = s->motion_val[(x) + (y) * wrap];
/* special case for first line */
if (y == 1 || s->first_slice_line) {
if (y == 1 || s->first_slice_line || s->first_gob_line) {
A = s->motion_val[(x-1) + (y) * wrap];
*px = A[0];
*py = A[1];
@ -779,32 +779,32 @@ int h263_decode_mb(MpegEncContext *s,
unsigned int val;
INT16 *mot_val;
static INT8 quant_tab[4] = { -1, -2, 1, 2 };
unsigned int gfid;
/* Check for GOB Start Code */
val = show_bits(&s->gb, 16);
if (val == 0) {
/* We have a GBSC probably with GSTUFF */
#ifdef DEBUG
unsigned int gn, gfid;
#endif
//skip_bits(&s->gb, 16); /* Drop the zeros */
while (get_bits1(&s->gb) == 0); /* Seek the '1' bit */
#ifdef DEBUG
fprintf(stderr,"\nGOB Start Code at MB %d\n",
(s->mb_y * s->mb_width) + s->mb_x);
gn = get_bits(&s->gb, 5); /* GN */
#endif
s->gob_number = get_bits(&s->gb, 5); /* GN */
gfid = get_bits(&s->gb, 2); /* GFID */
#else
skip_bits(&s->gb, 5); /* GN */
skip_bits(&s->gb, 2); /* GFID */
#endif
s->qscale = get_bits(&s->gb, 5); /* GQUANT */
#ifdef DEBUG
fprintf(stderr, "\nGN: %u GFID: %u Quant: %u\n", gn, gfid, s->qscale);
#endif
}
if (s->mb_y == s->gob_number)
s->first_gob_line = 1;
else
s->first_gob_line = 0;
if (s->pict_type == P_TYPE) {
if (get_bits1(&s->gb)) {
/* skip mb */
@ -863,6 +863,9 @@ int h263_decode_mb(MpegEncContext *s,
return -1;
s->mv[0][0][0] = mx;
s->mv[0][0][1] = my;
/*fprintf(stderr, "\n MB %d", (s->mb_y * s->mb_width) + s->mb_x);
fprintf(stderr, "\n\tmvx: %d\t\tpredx: %d", mx, pred_x);
fprintf(stderr, "\n\tmvy: %d\t\tpredy: %d", my, pred_y);*/
if (s->umvplus_dec && (mx - pred_x) == 1 && (my - pred_y) == 1)
skip_bits1(&s->gb); /* Bit stuffing to prevent PSC */
@ -957,6 +960,7 @@ static int h263_decode_motion(MpegEncContext * s, int pred)
val += 64;
if (pred > 32 && val > 63)
val -= 64;
}
return val;
}
@ -1211,6 +1215,10 @@ int h263_decode_picture_header(MpegEncContext *s)
skip_bits1(&s->gb); /* camera off */
skip_bits1(&s->gb); /* freeze picture release off */
/* Reset GOB data */
s->gob_number = 0;
s->first_gob_line = 0;
format = get_bits(&s->gb, 3);
if (format != 7) {

View File

@ -39,6 +39,8 @@ static int h263_decode_init(AVCodecContext *avctx)
/* select sub codec */
switch(avctx->codec->id) {
case CODEC_ID_H263:
s->gob_number = 0;
s->first_gob_line = 0;
break;
case CODEC_ID_MPEG4:
s->time_increment_bits = 4; /* default value for broken headers */

View File

@ -129,6 +129,10 @@ typedef struct MpegEncContext {
INT64 wanted_bits;
INT64 total_bits;
/* H.263 specific */
int gob_number;
int first_gob_line;
/* H.263+ specific */
int umvplus;
int umvplus_dec;