[FFmpeg-devel,06/12] avformat/mxfdec: make current_edit_unit a parameter of mxf_compute_samples

Submitted by Marton Balint on June 10, 2018, 10:36 a.m.

Details

Message ID 20180610103650.10155-6-cus@passwd.hu
State Accepted
Commit 1cea0e73d2b7844319fab4b7b07f2d62c2cf1733
Headers show

Commit Message

Marton Balint June 10, 2018, 10:36 a.m.
No change in functionality.

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

Comments

Tomas Härdin June 13, 2018, 3:08 p.m.
sön 2018-06-10 klockan 12:36 +0200 skrev Marton Balint:
> No change in functionality.
> 
> > Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
>  libavformat/mxfdec.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
> index be6884edbe..8e099164aa 100644
> --- a/libavformat/mxfdec.c
> +++ b/libavformat/mxfdec.c
> @@ -3215,7 +3215,7 @@ static int64_t mxf_set_current_edit_unit(MXFContext *mxf, int64_t current_offset
>  }
>  
>  static int mxf_compute_sample_count(MXFContext *mxf, int stream_index,
> -                                    uint64_t *sample_count)
> +                                    int64_t edit_unit, uint64_t *sample_count)
>  {
>      int i, total = 0, size = 0;
>      AVStream *st = mxf->fc->streams[stream_index];
> @@ -3229,7 +3229,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_rescale_q(mxf->current_edit_unit, sample_rate, track->edit_rate);
> +        *sample_count = av_rescale_q(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 "
> @@ -3246,8 +3246,8 @@ static int mxf_compute_sample_count(MXFContext *mxf, int stream_index,
>  
>      av_assert2(size);
>  
> -    *sample_count = (mxf->current_edit_unit / size) * (uint64_t)total;
> -    for (i = 0; i < mxf->current_edit_unit % size; i++) {
> +    *sample_count = (edit_unit / size) * (uint64_t)total;
> +    for (i = 0; i < edit_unit % size; i++) {
>          *sample_count += spf->samples_per_frame[i];
>      }
>  
> @@ -3595,7 +3595,7 @@ static int mxf_read_seek(AVFormatContext *s, int stream_index, int64_t sample_ti
>                                                         cur_st->time_base);
>              } else {
>                  uint64_t current_sample_count = 0;
> -                ret = mxf_compute_sample_count(mxf, i, &current_sample_count);
> +                ret = mxf_compute_sample_count(mxf, i, sample_time, &current_sample_count);
>                  if (ret < 0)
>                      return ret;
>                  cur_track->sample_count = current_sample_count;

Simple enough

/Tomas

Patch hide | download patch | download mbox

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index be6884edbe..8e099164aa 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -3215,7 +3215,7 @@  static int64_t mxf_set_current_edit_unit(MXFContext *mxf, int64_t current_offset
 }
 
 static int mxf_compute_sample_count(MXFContext *mxf, int stream_index,
-                                    uint64_t *sample_count)
+                                    int64_t edit_unit, uint64_t *sample_count)
 {
     int i, total = 0, size = 0;
     AVStream *st = mxf->fc->streams[stream_index];
@@ -3229,7 +3229,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_rescale_q(mxf->current_edit_unit, sample_rate, track->edit_rate);
+        *sample_count = av_rescale_q(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 "
@@ -3246,8 +3246,8 @@  static int mxf_compute_sample_count(MXFContext *mxf, int stream_index,
 
     av_assert2(size);
 
-    *sample_count = (mxf->current_edit_unit / size) * (uint64_t)total;
-    for (i = 0; i < mxf->current_edit_unit % size; i++) {
+    *sample_count = (edit_unit / size) * (uint64_t)total;
+    for (i = 0; i < edit_unit % size; i++) {
         *sample_count += spf->samples_per_frame[i];
     }
 
@@ -3595,7 +3595,7 @@  static int mxf_read_seek(AVFormatContext *s, int stream_index, int64_t sample_ti
                                                        cur_st->time_base);
             } else {
                 uint64_t current_sample_count = 0;
-                ret = mxf_compute_sample_count(mxf, i, &current_sample_count);
+                ret = mxf_compute_sample_count(mxf, i, sample_time, &current_sample_count);
                 if (ret < 0)
                     return ret;
                 cur_track->sample_count = current_sample_count;