diff mbox

[FFmpeg-devel,1/3] cbs_av1: Fix header writing when already aligned

Message ID 20181105001045.24545-1-sw@jkqxz.net
State Accepted
Commit 6bdb7712ae0267ba4f69c7434d2b3dee12762d1d
Headers show

Commit Message

Mark Thompson Nov. 5, 2018, 12:10 a.m. UTC
---
Previously it lost the trailing bits byte but did include it in the OBU size, completely breaking the stream.


 libavcodec/cbs_av1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

James Almer Nov. 5, 2018, 1:14 p.m. UTC | #1
On 11/4/2018 9:10 PM, Mark Thompson wrote:
> ---
> Previously it lost the trailing bits byte but did include it in the OBU size, completely breaking the stream.
> 
> 
>  libavcodec/cbs_av1.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c
> index 9bac9dde09..1c49d90f51 100644
> --- a/libavcodec/cbs_av1.c
> +++ b/libavcodec/cbs_av1.c
> @@ -1179,7 +1179,7 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx,
>          if (err < 0)
>              return err;
>          end_pos = put_bits_count(pbc);
> -        obu->obu_size = (end_pos - start_pos + 7) / 8;
> +        obu->obu_size = header_size = (end_pos - start_pos + 7) / 8;
>      } else {
>          // Empty OBU.
>          obu->obu_size = 0;
> 

What samples was this breaking? The few i tried have matching checksum
after an av1_metadata passthrough.
Mark Thompson Nov. 5, 2018, 2:12 p.m. UTC | #2
On 05/11/18 13:14, James Almer wrote:
> On 11/4/2018 9:10 PM, Mark Thompson wrote:
>> ---
>> Previously it lost the trailing bits byte but did include it in the OBU size, completely breaking the stream.
>>
>>
>>  libavcodec/cbs_av1.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c
>> index 9bac9dde09..1c49d90f51 100644
>> --- a/libavcodec/cbs_av1.c
>> +++ b/libavcodec/cbs_av1.c
>> @@ -1179,7 +1179,7 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx,
>>          if (err < 0)
>>              return err;
>>          end_pos = put_bits_count(pbc);
>> -        obu->obu_size = (end_pos - start_pos + 7) / 8;
>> +        obu->obu_size = header_size = (end_pos - start_pos + 7) / 8;
>>      } else {
>>          // Empty OBU.
>>          obu->obu_size = 0;
>>
> 
> What samples was this breaking? The few i tried have matching checksum
> after an av1_metadata passthrough.

Your s6Nh.ivf file with redundant headers requires it.  (I spent quite a while banging my head against that one, because the write trace showed exactly the right thing but then reading it back was messed up.)

- Mark
James Almer Nov. 5, 2018, 2:24 p.m. UTC | #3
On 11/5/2018 11:12 AM, Mark Thompson wrote:
> On 05/11/18 13:14, James Almer wrote:
>> On 11/4/2018 9:10 PM, Mark Thompson wrote:
>>> ---
>>> Previously it lost the trailing bits byte but did include it in the OBU size, completely breaking the stream.
>>>
>>>
>>>  libavcodec/cbs_av1.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c
>>> index 9bac9dde09..1c49d90f51 100644
>>> --- a/libavcodec/cbs_av1.c
>>> +++ b/libavcodec/cbs_av1.c
>>> @@ -1179,7 +1179,7 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx,
>>>          if (err < 0)
>>>              return err;
>>>          end_pos = put_bits_count(pbc);
>>> -        obu->obu_size = (end_pos - start_pos + 7) / 8;
>>> +        obu->obu_size = header_size = (end_pos - start_pos + 7) / 8;
>>>      } else {
>>>          // Empty OBU.
>>>          obu->obu_size = 0;
>>>
>>
>> What samples was this breaking? The few i tried have matching checksum
>> after an av1_metadata passthrough.
> 
> Your s6Nh.ivf file with redundant headers requires it.  (I spent quite a while banging my head against that one, because the write trace showed exactly the right thing but then reading it back was messed up.)
> 
> - Mark

Right, it was a dep for patch 2.

LGTM then.
diff mbox

Patch

diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c
index 9bac9dde09..1c49d90f51 100644
--- a/libavcodec/cbs_av1.c
+++ b/libavcodec/cbs_av1.c
@@ -1179,7 +1179,7 @@  static int cbs_av1_write_obu(CodedBitstreamContext *ctx,
         if (err < 0)
             return err;
         end_pos = put_bits_count(pbc);
-        obu->obu_size = (end_pos - start_pos + 7) / 8;
+        obu->obu_size = header_size = (end_pos - start_pos + 7) / 8;
     } else {
         // Empty OBU.
         obu->obu_size = 0;