diff mbox

[FFmpeg-devel,2/5] avformat/mxfdec: use int math for sample count calculation

Message ID 20180527192154.25996-2-cus@passwd.hu
State Accepted
Commit e7498792b65683aa723ca1877f30e20e640e3467
Headers show

Commit Message

Marton Balint May 27, 2018, 7:21 p.m. UTC
This also changes the rounding to nearest.

Signed-off-by: Marton Balint <cus@passwd.hu>
---
 libavformat/mxfdec.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Tomas Härdin May 27, 2018, 9:20 p.m. UTC | #1
sön 2018-05-27 klockan 21:21 +0200 skrev Marton Balint:
> This also changes the rounding to nearest.
> 
> > Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
>  libavformat/mxfdec.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
> index 40c9e0c3a9..78a2aa7289 100644
> --- a/libavformat/mxfdec.c
> +++ b/libavformat/mxfdec.c
> @@ -3167,8 +3167,7 @@ static int mxf_compute_sample_count(MXFContext *mxf, int stream_index,
>      if (!spf) {
>          int remainder = (sample_rate.num * time_base.num) %
>                          (time_base.den * sample_rate.den);
> -        *sample_count = av_q2d(av_mul_q((AVRational){mxf->current_edit_unit, 1},
> -                                        av_mul_q(sample_rate, time_base)));
> +        *sample_count = av_rescale_q(mxf->current_edit_unit, sample_rate, track->edit_rate);
>          if (remainder)
>              av_log(mxf->fc, AV_LOG_WARNING,
>                     "seeking detected on stream #%d with time base (%d/%d) and "

Looks OK, cleaner too

/Tomas
diff mbox

Patch

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 40c9e0c3a9..78a2aa7289 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -3167,8 +3167,7 @@  static int mxf_compute_sample_count(MXFContext *mxf, int stream_index,
     if (!spf) {
         int remainder = (sample_rate.num * time_base.num) %
                         (time_base.den * sample_rate.den);
-        *sample_count = av_q2d(av_mul_q((AVRational){mxf->current_edit_unit, 1},
-                                        av_mul_q(sample_rate, time_base)));
+        *sample_count = av_rescale_q(mxf->current_edit_unit, sample_rate, track->edit_rate);
         if (remainder)
             av_log(mxf->fc, AV_LOG_WARNING,
                    "seeking detected on stream #%d with time base (%d/%d) and "