Commit fb4a4a56 authored by Fabrice Bellard's avatar Fabrice Bellard

mpeg1/2 identifier - fixed frame rate for some bad mpeg1 streams

Originally committed as revision 542 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 4d7a0a05
...@@ -1283,6 +1283,7 @@ static void mpeg_decode_sequence_extension(MpegEncContext *s) ...@@ -1283,6 +1283,7 @@ static void mpeg_decode_sequence_extension(MpegEncContext *s)
s->frame_rate = (s->frame_rate * frame_rate_ext_n) / frame_rate_ext_d; s->frame_rate = (s->frame_rate * frame_rate_ext_n) / frame_rate_ext_d;
dprintf("sequence extension\n"); dprintf("sequence extension\n");
s->mpeg2 = 1; s->mpeg2 = 1;
s->avctx->sub_id = 2; /* indicates mpeg2 found */
} }
static void mpeg_decode_quant_matrix_extension(MpegEncContext *s) static void mpeg_decode_quant_matrix_extension(MpegEncContext *s)
...@@ -1472,7 +1473,7 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx, ...@@ -1472,7 +1473,7 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx,
Mpeg1Context *s1 = avctx->priv_data; Mpeg1Context *s1 = avctx->priv_data;
MpegEncContext *s = &s1->mpeg_enc_ctx; MpegEncContext *s = &s1->mpeg_enc_ctx;
int width, height, i, v, j; int width, height, i, v, j;
init_get_bits(&s->gb, buf, buf_size); init_get_bits(&s->gb, buf, buf_size);
width = get_bits(&s->gb, 12); width = get_bits(&s->gb, 12);
...@@ -1500,7 +1501,12 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx, ...@@ -1500,7 +1501,12 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx,
s->avctx = avctx; s->avctx = avctx;
avctx->width = width; avctx->width = width;
avctx->height = height; avctx->height = height;
avctx->frame_rate = frame_rate_tab[s->frame_rate_index]; if (s->frame_rate_index >= 9) {
/* at least give a valid frame rate (some old mpeg1 have this) */
avctx->frame_rate = 25 * FRAME_RATE_BASE;
} else {
avctx->frame_rate = frame_rate_tab[s->frame_rate_index];
}
s->frame_rate = avctx->frame_rate; s->frame_rate = avctx->frame_rate;
avctx->bit_rate = s->bit_rate; avctx->bit_rate = s->bit_rate;
...@@ -1561,6 +1567,7 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx, ...@@ -1561,6 +1567,7 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx,
s->picture_structure = PICT_FRAME; s->picture_structure = PICT_FRAME;
s->frame_pred_frame_dct = 1; s->frame_pred_frame_dct = 1;
s->mpeg2 = 0; s->mpeg2 = 0;
avctx->sub_id = 1; /* indicates mpeg1 */
return 0; return 0;
} }
......
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