[1/3] rtpenc: Cast a rescaling parameter to int64_t

Message ID 1322688143-57029-1-git-send-email-martin@martin.st
State Committed
Commit 2d31d890bfce103512dca34e35815762eb61b5da
Headers show

Commit Message

Martin Storsjö Nov. 30, 2011, 9:22 p.m.
This avoids overflow if frame_size is over 2147, since both
frame_size and AV_TIME_BASE are plain integers.
---
 libavformat/rtpenc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Justin Ruggles Dec. 1, 2011, 3:29 p.m. | #1
On 11/30/2011 04:22 PM, Martin Storsjö wrote:

> This avoids overflow if frame_size is over 2147, since both
> frame_size and AV_TIME_BASE are plain integers.
> ---
>  libavformat/rtpenc.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c
> index 77ae6f3..88b85b9 100644
> --- a/libavformat/rtpenc.c
> +++ b/libavformat/rtpenc.c
> @@ -121,7 +121,7 @@ static int rtp_write_header(AVFormatContext *s1)
>              if (st->codec->frame_size == 0) {
>                  av_log(s1, AV_LOG_ERROR, "Cannot respect max delay: frame size = 0\n");
>              } else {
> -                s->max_frames_per_packet = av_rescale_rnd(s1->max_delay, st->codec->sample_rate, AV_TIME_BASE * st->codec->frame_size, AV_ROUND_DOWN);
> +                s->max_frames_per_packet = av_rescale_rnd(s1->max_delay, st->codec->sample_rate, AV_TIME_BASE * (int64_t)st->codec->frame_size, AV_ROUND_DOWN);
>              }
>          }
>          if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {


lgtm.

-Justin

Patch

diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c
index 77ae6f3..88b85b9 100644
--- a/libavformat/rtpenc.c
+++ b/libavformat/rtpenc.c
@@ -121,7 +121,7 @@  static int rtp_write_header(AVFormatContext *s1)
             if (st->codec->frame_size == 0) {
                 av_log(s1, AV_LOG_ERROR, "Cannot respect max delay: frame size = 0\n");
             } else {
-                s->max_frames_per_packet = av_rescale_rnd(s1->max_delay, st->codec->sample_rate, AV_TIME_BASE * st->codec->frame_size, AV_ROUND_DOWN);
+                s->max_frames_per_packet = av_rescale_rnd(s1->max_delay, st->codec->sample_rate, AV_TIME_BASE * (int64_t)st->codec->frame_size, AV_ROUND_DOWN);
             }
         }
         if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {