[FFmpeg-devel,4/5] avformat/mxfdec: take into account run-in in find_partition_by_offset

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

Details

Message ID 20190411230920.6630-4-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 | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Tomas Härdin April 14, 2019, 3:58 p.m.
fre 2019-04-12 klockan 01:09 +0200 skrev Marton Balint:
> > Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
>  libavformat/mxfdec.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
> index 236294880e..6f0f87763d 100644
> --- a/libavformat/mxfdec.c
> +++ b/libavformat/mxfdec.c
> @@ -433,15 +433,15 @@ static int find_body_sid_by_offset(MXFContext *mxf, int64_t offset)

Maybe we should rename the function to make it clear offset is
absolute?

>  {
>      // we look for partition where the offset is placed
>      int a, b, m;
> -    int64_t this_partition;
> +    int64_t pack_ofs;
>  
>      a = -1;
>      b = mxf->partitions_count;
>  
>      while (b - a > 1) {
> -        m         = (a + b) >> 1;
> -        this_partition = mxf->partitions[m].this_partition;
> -        if (this_partition <= offset)
> +        m = (a + b) >> 1;
> +        pack_ofs = mxf->partitions[m].pack_ofs;
> +        if (pack_ofs <= offset)
>              a = m;
>          else
>              b = m;

Looks OK otherwise

/Tomas

Patch hide | download patch | download mbox

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 236294880e..6f0f87763d 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -433,15 +433,15 @@  static int find_body_sid_by_offset(MXFContext *mxf, int64_t offset)
 {
     // we look for partition where the offset is placed
     int a, b, m;
-    int64_t this_partition;
+    int64_t pack_ofs;
 
     a = -1;
     b = mxf->partitions_count;
 
     while (b - a > 1) {
-        m         = (a + b) >> 1;
-        this_partition = mxf->partitions[m].this_partition;
-        if (this_partition <= offset)
+        m = (a + b) >> 1;
+        pack_ofs = mxf->partitions[m].pack_ofs;
+        if (pack_ofs <= offset)
             a = m;
         else
             b = m;