[FFmpeg-devel,1/5] avformat/mxfdec: pass track to mxf_edit_unit_absolute_offset instead of arbitrary edit unit

Submitted by Marton Balint on April 11, 2019, 11:09 p.m.

Details

Message ID 20190411230920.6630-1-cus@passwd.hu
State New
Headers show

Commit Message

Marton Balint April 11, 2019, 11:09 p.m.
Signed-off-by: Marton Balint <cus@passwd.hu>
---
 libavformat/mxfdec.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Tomas Härdin April 14, 2019, 3:57 p.m.
fre 2019-04-12 klockan 01:09 +0200 skrev Marton Balint:
> > Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
>  libavformat/mxfdec.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
> index 8c65a2bbcf..c3892a1037 100644
> --- a/libavformat/mxfdec.c
> +++ b/libavformat/mxfdec.c
> @@ -1564,12 +1564,12 @@ static int64_t mxf_essence_container_end(MXFContext *mxf, int body_sid)
>  }
>  
>  /* EditUnit -> absolute offset */
> -static int mxf_edit_unit_absolute_offset(MXFContext *mxf, MXFIndexTable *index_table, int64_t edit_unit, AVRational edit_rate, int64_t *edit_unit_out, int64_t *offset_out, MXFPartition **partition_out, int nag)
> +static int mxf_edit_unit_absolute_offset(MXFContext *mxf, MXFTrack *track, MXFIndexTable *index_table, int64_t edit_unit, int64_t *edit_unit_out, int64_t *offset_out, MXFPartition **partition_out, int nag)

Why? Either way, you could break this line up while you're at it

/Tomas

Patch hide | download patch | download mbox

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 8c65a2bbcf..c3892a1037 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -1564,12 +1564,12 @@  static int64_t mxf_essence_container_end(MXFContext *mxf, int body_sid)
 }
 
 /* EditUnit -> absolute offset */
-static int mxf_edit_unit_absolute_offset(MXFContext *mxf, MXFIndexTable *index_table, int64_t edit_unit, AVRational edit_rate, int64_t *edit_unit_out, int64_t *offset_out, MXFPartition **partition_out, int nag)
+static int mxf_edit_unit_absolute_offset(MXFContext *mxf, MXFTrack *track, MXFIndexTable *index_table, int64_t edit_unit, int64_t *edit_unit_out, int64_t *offset_out, MXFPartition **partition_out, int nag)
 {
     int i;
     int64_t offset_temp = 0;
 
-    edit_unit = av_rescale_q(edit_unit, index_table->segments[0]->index_edit_rate, edit_rate);
+    edit_unit = av_rescale_q(edit_unit, index_table->segments[0]->index_edit_rate, track->edit_rate);
 
     for (i = 0; i < index_table->nb_segments; i++) {
         MXFIndexTableSegment *s = index_table->segments[i];
@@ -1595,7 +1595,7 @@  static int mxf_edit_unit_absolute_offset(MXFContext *mxf, MXFIndexTable *index_t
             }
 
             if (edit_unit_out)
-                *edit_unit_out = av_rescale_q(edit_unit, edit_rate, s->index_edit_rate);
+                *edit_unit_out = av_rescale_q(edit_unit, track->edit_rate, s->index_edit_rate);
 
             return mxf_absolute_bodysid_offset(mxf, index_table->body_sid, offset_temp, offset_out, partition_out);
         } else {
@@ -3271,7 +3271,7 @@  static int mxf_get_next_track_edit_unit(MXFContext *mxf, MXFTrack *track, int64_
 
     while (b - a > 1) {
         m = (a + b) >> 1;
-        if (mxf_edit_unit_absolute_offset(mxf, t, m, track->edit_rate, NULL, &offset, NULL, 0) < 0)
+        if (mxf_edit_unit_absolute_offset(mxf, track, t, m, NULL, &offset, NULL, 0) < 0)
             return -1;
         if (offset < current_offset)
             a = m;
@@ -3343,7 +3343,7 @@  static int64_t mxf_set_current_edit_unit(MXFContext *mxf, AVStream *st, int64_t
     if (!t || track->wrapping == UnknownWrapped)
         return -1;
 
-    if (mxf_edit_unit_absolute_offset(mxf, t, edit_unit + track->edit_units_per_packet, track->edit_rate, NULL, &next_ofs, NULL, 0) < 0 &&
+    if (mxf_edit_unit_absolute_offset(mxf, track, t, edit_unit + track->edit_units_per_packet, NULL, &next_ofs, NULL, 0) < 0 &&
         (next_ofs = mxf_essence_container_end(mxf, t->body_sid)) <= 0) {
         av_log(mxf->fc, AV_LOG_ERROR, "unable to compute the size of the last packet\n");
         return -1;
@@ -3687,7 +3687,7 @@  static int mxf_read_seek(AVFormatContext *s, int stream_index, int64_t sample_ti
         if (source_track->wrapping == UnknownWrapped)
             av_log(mxf->fc, AV_LOG_WARNING, "attempted seek in an UnknownWrapped essence\n");
 
-        if ((ret = mxf_edit_unit_absolute_offset(mxf, t, sample_time, source_track->edit_rate, &sample_time, &seekpos, &partition, 1)) < 0)
+        if ((ret = mxf_edit_unit_absolute_offset(mxf, source_track, t, sample_time, &sample_time, &seekpos, &partition, 1)) < 0)
             return ret;
 
         ff_update_cur_dts(s, st, sample_time);