[FFmpeg-devel] avformat/mxfenc: fix index byte count in partition header

Submitted by Baptiste Coudurier on July 18, 2019, 6:39 p.m.

Details

Message ID 20190718183905.14228-1-baptiste.coudurier@gmail.com
State Accepted
Commit 9e24b98b15cbec1e0212d909ad29c746e1d1738b
Headers show

Commit Message

Baptiste Coudurier July 18, 2019, 6:39 p.m.
---
 libavformat/mxfenc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Tomas Härdin July 19, 2019, 3:48 p.m.
tor 2019-07-18 klockan 11:39 -0700 skrev Baptiste Coudurier:
> ---
>  libavformat/mxfenc.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
> index b677f6af8e..2e54320cf0 100644
> --- a/libavformat/mxfenc.c
> +++ b/libavformat/mxfenc.c
> @@ -1944,8 +1944,7 @@ static int mxf_write_partition(AVFormatContext
> *s, int bodysid,
>          index_byte_count = 80;
>  
>      if (index_byte_count) {
> -        // add encoded ber length
> -        index_byte_count += 16 + klv_ber_length(index_byte_count);
> +        index_byte_count += 16 + 4; // add encoded ber4 length
>          index_byte_count += klv_fill_size(index_byte_count);
>      }
>  

Is there a reason why we don't pick a single BER length coding for the
entire muxer?

/Tomas
Baptiste Coudurier July 19, 2019, 4:51 p.m.
Hi Tomas

> On Jul 19, 2019, at 8:48 AM, Tomas Härdin <tjoppen@acc.umu.se> wrote:
> 
> tor 2019-07-18 klockan 11:39 -0700 skrev Baptiste Coudurier:
>> ---
>> libavformat/mxfenc.c | 3 +--
>> 1 file changed, 1 insertion(+), 2 deletions(-)
>> 
>> diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
>> index b677f6af8e..2e54320cf0 100644
>> --- a/libavformat/mxfenc.c
>> +++ b/libavformat/mxfenc.c
>> @@ -1944,8 +1944,7 @@ static int mxf_write_partition(AVFormatContext
>> *s, int bodysid,
>>         index_byte_count = 80;
>> 
>>     if (index_byte_count) {
>> -        // add encoded ber length
>> -        index_byte_count += 16 + klv_ber_length(index_byte_count);
>> +        index_byte_count += 16 + 4; // add encoded ber4 length
>>         index_byte_count += klv_fill_size(index_byte_count);
>>     }
>> 
> 
> Is there a reason why we don't pick a single BER length coding for the
> entire muxer?

BER It saves space, BER4 is only used when required. No strong opinion,
I think it’s unrelated to this fix though.

— 
Baptiste
Tomas Härdin July 22, 2019, 9:45 a.m.
fre 2019-07-19 klockan 09:51 -0700 skrev Baptiste Coudurier:
> Hi Tomas
> 
> > On Jul 19, 2019, at 8:48 AM, Tomas Härdin <tjoppen@acc.umu.se>
> > wrote:
> > 
> > tor 2019-07-18 klockan 11:39 -0700 skrev Baptiste Coudurier:
> > > ---
> > > libavformat/mxfenc.c | 3 +--
> > > 1 file changed, 1 insertion(+), 2 deletions(-)
> > > 
> > > diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
> > > index b677f6af8e..2e54320cf0 100644
> > > --- a/libavformat/mxfenc.c
> > > +++ b/libavformat/mxfenc.c
> > > @@ -1944,8 +1944,7 @@ static int
> > > mxf_write_partition(AVFormatContext
> > > *s, int bodysid,
> > >         index_byte_count = 80;
> > > 
> > >     if (index_byte_count) {
> > > -        // add encoded ber length
> > > -        index_byte_count += 16 +
> > > klv_ber_length(index_byte_count);
> > > +        index_byte_count += 16 + 4; // add encoded ber4 length
> > >         index_byte_count += klv_fill_size(index_byte_count);
> > >     }
> > > 
> > 
> > Is there a reason why we don't pick a single BER length coding for
> > the
> > entire muxer?
> 
> BER It saves space, BER4 is only used when required. No strong
> opinion,
> I think it’s unrelated to this fix though.

Sorry about the late reply. But yeah, just thought it was a bit
strange. BER4 does make computing sizes much easier where possible. The
patch itself is obviously fine

/Tomas
Baptiste Coudurier July 22, 2019, 8:19 p.m.
Hi Tomas,


> On Jul 22, 2019, at 2:45 AM, Tomas Härdin <tjoppen@acc.umu.se> wrote:
> 
> fre 2019-07-19 klockan 09:51 -0700 skrev Baptiste Coudurier:
>> Hi Tomas
>> 
>>> On Jul 19, 2019, at 8:48 AM, Tomas Härdin <tjoppen@acc.umu.se>
>>> wrote:
>>> 
>>> tor 2019-07-18 klockan 11:39 -0700 skrev Baptiste Coudurier:
>>>> ---
>>>> libavformat/mxfenc.c | 3 +--
>>>> 1 file changed, 1 insertion(+), 2 deletions(-)
>>>> 
>>>> diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
>>>> index b677f6af8e..2e54320cf0 100644
>>>> --- a/libavformat/mxfenc.c
>>>> +++ b/libavformat/mxfenc.c
>>>> @@ -1944,8 +1944,7 @@ static int
>>>> mxf_write_partition(AVFormatContext
>>>> *s, int bodysid,
>>>>        index_byte_count = 80;
>>>> 
>>>>    if (index_byte_count) {
>>>> -        // add encoded ber length
>>>> -        index_byte_count += 16 +
>>>> klv_ber_length(index_byte_count);
>>>> +        index_byte_count += 16 + 4; // add encoded ber4 length
>>>>        index_byte_count += klv_fill_size(index_byte_count);
>>>>    }
>>>> 
>>> 
>>> Is there a reason why we don't pick a single BER length coding for
>>> the
>>> entire muxer?
>> 
>> BER It saves space, BER4 is only used when required. No strong
>> opinion,
>> I think it’s unrelated to this fix though.
> 
> Sorry about the late reply. But yeah, just thought it was a bit
> strange. BER4 does make computing sizes much easier where possible. The
> patch itself is obviously fine

No worries. Yeah I kinda agree.

Applied.

Thanks a lot!

— 
Baptiste

Patch hide | download patch | download mbox

diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index b677f6af8e..2e54320cf0 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -1944,8 +1944,7 @@  static int mxf_write_partition(AVFormatContext *s, int bodysid,
         index_byte_count = 80;
 
     if (index_byte_count) {
-        // add encoded ber length
-        index_byte_count += 16 + klv_ber_length(index_byte_count);
+        index_byte_count += 16 + 4; // add encoded ber4 length
         index_byte_count += klv_fill_size(index_byte_count);
     }