Commit ba6c5e14 authored by michaelni's avatar michaelni

avoid overflow of picturenumber*fps*10000

bug found by Lennert Buytenhek <buytenh@gnu.org>


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@302 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 3eafd8ae
...@@ -68,7 +68,7 @@ void h263_encode_picture_header(MpegEncContext * s, int picture_number) ...@@ -68,7 +68,7 @@ void h263_encode_picture_header(MpegEncContext * s, int picture_number)
s->gob_number = 0; s->gob_number = 0;
put_bits(&s->pb, 22, 0x20); /* PSC */ put_bits(&s->pb, 22, 0x20); /* PSC */
put_bits(&s->pb, 8, ((s->picture_number * 30 * FRAME_RATE_BASE) / put_bits(&s->pb, 8, (((INT64)s->picture_number * 30 * FRAME_RATE_BASE) /
s->frame_rate) & 0xff); s->frame_rate) & 0xff);
put_bits(&s->pb, 1, 1); /* marker */ put_bits(&s->pb, 1, 1); /* marker */
......
...@@ -106,7 +106,7 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s) ...@@ -106,7 +106,7 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
/* time code : we must convert from the real frame rate to a /* time code : we must convert from the real frame rate to a
fake mpeg frame rate in case of low frame rate */ fake mpeg frame rate in case of low frame rate */
fps = frame_rate_tab[s->frame_rate_index]; fps = frame_rate_tab[s->frame_rate_index];
time_code = s->fake_picture_number * FRAME_RATE_BASE; time_code = (INT64)s->fake_picture_number * FRAME_RATE_BASE;
s->gop_picture_number = s->fake_picture_number; s->gop_picture_number = s->fake_picture_number;
put_bits(&s->pb, 5, (UINT32)((time_code / (fps * 3600)) % 24)); put_bits(&s->pb, 5, (UINT32)((time_code / (fps * 3600)) % 24));
put_bits(&s->pb, 6, (UINT32)((time_code / (fps * 60)) % 60)); put_bits(&s->pb, 6, (UINT32)((time_code / (fps * 60)) % 60));
...@@ -121,7 +121,7 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s) ...@@ -121,7 +121,7 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
/* insert empty P pictures to slow down to the desired /* insert empty P pictures to slow down to the desired
frame rate. Each fake pictures takes about 20 bytes */ frame rate. Each fake pictures takes about 20 bytes */
fps = frame_rate_tab[s->frame_rate_index]; fps = frame_rate_tab[s->frame_rate_index];
n = ((s->picture_number * fps) / s->frame_rate) - 1; n = (((INT64)s->picture_number * fps) / s->frame_rate) - 1;
while (s->fake_picture_number < n) { while (s->fake_picture_number < n) {
mpeg1_skip_picture(s, s->fake_picture_number - mpeg1_skip_picture(s, s->fake_picture_number -
s->gop_picture_number); s->gop_picture_number);
......
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