[FFmpeg-cvslog] avformat/mxfdec: rework mxf_essence_container_end

Marton Balint git at videolan.org
Sun Apr 28 23:08:28 EEST 2019


ffmpeg | branch: master | Marton Balint <cus at passwd.hu> | Sun Apr  7 02:06:35 2019 +0200| [a5136426a73261e5b5a493f33944be82b6b659c6] | committer: Marton Balint

avformat/mxfdec: rework mxf_essence_container_end

We find the last essence container much faster if we go through the partitions
backwards...

Signed-off-by: Marton Balint <cus at passwd.hu>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a5136426a73261e5b5a493f33944be82b6b659c6
---

 libavformat/mxfdec.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 3ea8de1666..2c44852062 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -1545,10 +1545,7 @@ static int mxf_absolute_bodysid_offset(MXFContext *mxf, int body_sid, int64_t of
  */
 static int64_t mxf_essence_container_end(MXFContext *mxf, int body_sid)
 {
-    int x;
-    int64_t ret = 0;
-
-    for (x = 0; x < mxf->partitions_count; x++) {
+    for (int x = mxf->partitions_count - 1; x >= 0; x--) {
         MXFPartition *p = &mxf->partitions[x];
 
         if (p->body_sid != body_sid)
@@ -1557,10 +1554,10 @@ static int64_t mxf_essence_container_end(MXFContext *mxf, int body_sid)
         if (!p->essence_length)
             return 0;
 
-        ret = p->essence_offset + p->essence_length;
+        return p->essence_offset + p->essence_length;
     }
 
-    return ret;
+    return 0;
 }
 
 /* EditUnit -> absolute offset */



More information about the ffmpeg-cvslog mailing list