diff mbox series

[FFmpeg-devel,2/3] avformat/av1: Add a parameter to av1c to omit seq header

Message ID 20220217055117.3233501-2-vigneshv@google.com
State New
Headers show
Series [FFmpeg-devel,1/3] avcodec/libaomenc: Add parameter for avif single image encoding | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Vignesh Venkatasubramanian Feb. 17, 2022, 5:51 a.m. UTC
Add a parameter to omit seq header when generating the av1C atom.

For now, this does not change any behavior. This will be used by a
follow-up patch to add AVIF support.

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
---
 libavformat/av1.c         | 7 +++++--
 libavformat/av1.h         | 4 +++-
 libavformat/matroskaenc.c | 4 ++--
 libavformat/movenc.c      | 2 +-
 4 files changed, 11 insertions(+), 6 deletions(-)

Comments

James Almer March 2, 2022, 10:57 p.m. UTC | #1
On 2/17/2022 2:51 AM, Vignesh Venkatasubramanian wrote:
> Add a parameter to omit seq header when generating the av1C atom.
> 
> For now, this does not change any behavior. This will be used by a
> follow-up patch to add AVIF support.
> 
> Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
> ---
>   libavformat/av1.c         | 7 +++++--
>   libavformat/av1.h         | 4 +++-
>   libavformat/matroskaenc.c | 4 ++--
>   libavformat/movenc.c      | 2 +-
>   4 files changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/libavformat/av1.c b/libavformat/av1.c
> index 1fcfac2356..95ca7cc47f 100644
> --- a/libavformat/av1.c
> +++ b/libavformat/av1.c
> @@ -361,7 +361,8 @@ int ff_av1_parse_seq_header(AV1SequenceParameters *seq, const uint8_t *buf, int
>       return AVERROR_INVALIDDATA;
>   }
>   
> -int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size)
> +int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size,
> +                       int write_seq_header)
>   {
>       AVIOContext *meta_pb;
>       AV1SequenceParameters seq_params;
> @@ -451,7 +452,9 @@ int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size)
>       flush_put_bits(&pbc);
>   
>       avio_write(pb, header, sizeof(header));
> -    avio_write(pb, seq, seq_size);
> +    if (write_seq_header) {
> +        avio_write(pb, seq, seq_size);
> +    }
>   
>       meta_size = avio_get_dyn_buf(meta_pb, &meta);
>       if (meta_size)
> diff --git a/libavformat/av1.h b/libavformat/av1.h
> index f57dabe986..a393fbb78f 100644
> --- a/libavformat/av1.h
> +++ b/libavformat/av1.h
> @@ -96,9 +96,11 @@ int ff_av1_parse_seq_header(AV1SequenceParameters *seq, const uint8_t *buf, int
>    * @param pb pointer to the AVIOContext where the av1C box shall be written
>    * @param buf input data buffer
>    * @param size size in bytes of the input data buffer
> + * @param write_seq_header If 1, Sequence Header OBU will be written inside the
> + *           av1C box. Otherwise, Sequence Header OBU will be omitted.
>    *
>    * @return >= 0 in case of success, a negative AVERROR code in case of failure
>    */
> -int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size);
> +int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size, int write_seq_header);
>   
>   #endif /* AVFORMAT_AV1_H */
> diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
> index 38d9485288..5061961283 100644
> --- a/libavformat/matroskaenc.c
> +++ b/libavformat/matroskaenc.c
> @@ -1087,7 +1087,7 @@ static int mkv_write_native_codecprivate(AVFormatContext *s, AVIOContext *pb,
>       case AV_CODEC_ID_AV1:
>           if (par->extradata_size)
>               return ff_isom_write_av1c(dyn_cp, par->extradata,
> -                                      par->extradata_size);
> +                                      par->extradata_size, 1);
>           else
>               put_ebml_void(pb, 4 + 3);
>           break;
> @@ -2663,7 +2663,7 @@ static int mkv_check_new_extra_data(AVFormatContext *s, const AVPacket *pkt)
>               ret = avio_open_dyn_buf(&dyn_cp);
>               if (ret < 0)
>                   return ret;
> -            ff_isom_write_av1c(dyn_cp, side_data, side_data_size);
> +            ff_isom_write_av1c(dyn_cp, side_data, side_data_size, 1);
>               codecpriv_size = avio_get_dyn_buf(dyn_cp, &codecpriv);
>               if ((ret = dyn_cp->error) < 0 ||
>                   !codecpriv_size && (ret = AVERROR_INVALIDDATA)) {
> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> index 4c868919ae..1a746a67fd 100644
> --- a/libavformat/movenc.c
> +++ b/libavformat/movenc.c
> @@ -1303,7 +1303,7 @@ static int mov_write_av1c_tag(AVIOContext *pb, MOVTrack *track)
>   
>       avio_wb32(pb, 0);
>       ffio_wfourcc(pb, "av1C");
> -    ff_isom_write_av1c(pb, track->vos_data, track->vos_len);
> +    ff_isom_write_av1c(pb, track->vos_data, track->vos_len, 1);
>       return update_size(pb, pos);
>   }
>   

This patch no longer applies.
Vignesh Venkatasubramanian March 2, 2022, 11:23 p.m. UTC | #2
On Wed, Mar 2, 2022 at 2:57 PM James Almer <jamrial@gmail.com> wrote:
>
> On 2/17/2022 2:51 AM, Vignesh Venkatasubramanian wrote:
> > Add a parameter to omit seq header when generating the av1C atom.
> >
> > For now, this does not change any behavior. This will be used by a
> > follow-up patch to add AVIF support.
> >
> > Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
> > ---
> >   libavformat/av1.c         | 7 +++++--
> >   libavformat/av1.h         | 4 +++-
> >   libavformat/matroskaenc.c | 4 ++--
> >   libavformat/movenc.c      | 2 +-
> >   4 files changed, 11 insertions(+), 6 deletions(-)
> >
> > diff --git a/libavformat/av1.c b/libavformat/av1.c
> > index 1fcfac2356..95ca7cc47f 100644
> > --- a/libavformat/av1.c
> > +++ b/libavformat/av1.c
> > @@ -361,7 +361,8 @@ int ff_av1_parse_seq_header(AV1SequenceParameters *seq, const uint8_t *buf, int
> >       return AVERROR_INVALIDDATA;
> >   }
> >
> > -int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size)
> > +int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size,
> > +                       int write_seq_header)
> >   {
> >       AVIOContext *meta_pb;
> >       AV1SequenceParameters seq_params;
> > @@ -451,7 +452,9 @@ int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size)
> >       flush_put_bits(&pbc);
> >
> >       avio_write(pb, header, sizeof(header));
> > -    avio_write(pb, seq, seq_size);
> > +    if (write_seq_header) {
> > +        avio_write(pb, seq, seq_size);
> > +    }
> >
> >       meta_size = avio_get_dyn_buf(meta_pb, &meta);
> >       if (meta_size)
> > diff --git a/libavformat/av1.h b/libavformat/av1.h
> > index f57dabe986..a393fbb78f 100644
> > --- a/libavformat/av1.h
> > +++ b/libavformat/av1.h
> > @@ -96,9 +96,11 @@ int ff_av1_parse_seq_header(AV1SequenceParameters *seq, const uint8_t *buf, int
> >    * @param pb pointer to the AVIOContext where the av1C box shall be written
> >    * @param buf input data buffer
> >    * @param size size in bytes of the input data buffer
> > + * @param write_seq_header If 1, Sequence Header OBU will be written inside the
> > + *           av1C box. Otherwise, Sequence Header OBU will be omitted.
> >    *
> >    * @return >= 0 in case of success, a negative AVERROR code in case of failure
> >    */
> > -int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size);
> > +int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size, int write_seq_header);
> >
> >   #endif /* AVFORMAT_AV1_H */
> > diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
> > index 38d9485288..5061961283 100644
> > --- a/libavformat/matroskaenc.c
> > +++ b/libavformat/matroskaenc.c
> > @@ -1087,7 +1087,7 @@ static int mkv_write_native_codecprivate(AVFormatContext *s, AVIOContext *pb,
> >       case AV_CODEC_ID_AV1:
> >           if (par->extradata_size)
> >               return ff_isom_write_av1c(dyn_cp, par->extradata,
> > -                                      par->extradata_size);
> > +                                      par->extradata_size, 1);
> >           else
> >               put_ebml_void(pb, 4 + 3);
> >           break;
> > @@ -2663,7 +2663,7 @@ static int mkv_check_new_extra_data(AVFormatContext *s, const AVPacket *pkt)
> >               ret = avio_open_dyn_buf(&dyn_cp);
> >               if (ret < 0)
> >                   return ret;
> > -            ff_isom_write_av1c(dyn_cp, side_data, side_data_size);
> > +            ff_isom_write_av1c(dyn_cp, side_data, side_data_size, 1);
> >               codecpriv_size = avio_get_dyn_buf(dyn_cp, &codecpriv);
> >               if ((ret = dyn_cp->error) < 0 ||
> >                   !codecpriv_size && (ret = AVERROR_INVALIDDATA)) {
> > diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> > index 4c868919ae..1a746a67fd 100644
> > --- a/libavformat/movenc.c
> > +++ b/libavformat/movenc.c
> > @@ -1303,7 +1303,7 @@ static int mov_write_av1c_tag(AVIOContext *pb, MOVTrack *track)
> >
> >       avio_wb32(pb, 0);
> >       ffio_wfourcc(pb, "av1C");
> > -    ff_isom_write_av1c(pb, track->vos_data, track->vos_len);
> > +    ff_isom_write_av1c(pb, track->vos_data, track->vos_len, 1);
> >       return update_size(pb, pos);
> >   }
> >
>
> This patch no longer applies.

I have generated a new patch after sync'ing to the latest master. I
did not notice any conflicts. Can you please check if the updated
patch applies?

> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
James Almer March 2, 2022, 11:27 p.m. UTC | #3
On 3/2/2022 8:23 PM, Vignesh Venkatasubramanian wrote:
> On Wed, Mar 2, 2022 at 2:57 PM James Almer <jamrial@gmail.com> wrote:
>>
>> On 2/17/2022 2:51 AM, Vignesh Venkatasubramanian wrote:
>>> Add a parameter to omit seq header when generating the av1C atom.
>>>
>>> For now, this does not change any behavior. This will be used by a
>>> follow-up patch to add AVIF support.
>>>
>>> Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
>>> ---
>>>    libavformat/av1.c         | 7 +++++--
>>>    libavformat/av1.h         | 4 +++-
>>>    libavformat/matroskaenc.c | 4 ++--
>>>    libavformat/movenc.c      | 2 +-
>>>    4 files changed, 11 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/libavformat/av1.c b/libavformat/av1.c
>>> index 1fcfac2356..95ca7cc47f 100644
>>> --- a/libavformat/av1.c
>>> +++ b/libavformat/av1.c
>>> @@ -361,7 +361,8 @@ int ff_av1_parse_seq_header(AV1SequenceParameters *seq, const uint8_t *buf, int
>>>        return AVERROR_INVALIDDATA;
>>>    }
>>>
>>> -int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size)
>>> +int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size,
>>> +                       int write_seq_header)
>>>    {
>>>        AVIOContext *meta_pb;
>>>        AV1SequenceParameters seq_params;
>>> @@ -451,7 +452,9 @@ int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size)
>>>        flush_put_bits(&pbc);
>>>
>>>        avio_write(pb, header, sizeof(header));
>>> -    avio_write(pb, seq, seq_size);
>>> +    if (write_seq_header) {
>>> +        avio_write(pb, seq, seq_size);
>>> +    }
>>>
>>>        meta_size = avio_get_dyn_buf(meta_pb, &meta);
>>>        if (meta_size)
>>> diff --git a/libavformat/av1.h b/libavformat/av1.h
>>> index f57dabe986..a393fbb78f 100644
>>> --- a/libavformat/av1.h
>>> +++ b/libavformat/av1.h
>>> @@ -96,9 +96,11 @@ int ff_av1_parse_seq_header(AV1SequenceParameters *seq, const uint8_t *buf, int
>>>     * @param pb pointer to the AVIOContext where the av1C box shall be written
>>>     * @param buf input data buffer
>>>     * @param size size in bytes of the input data buffer
>>> + * @param write_seq_header If 1, Sequence Header OBU will be written inside the
>>> + *           av1C box. Otherwise, Sequence Header OBU will be omitted.
>>>     *
>>>     * @return >= 0 in case of success, a negative AVERROR code in case of failure
>>>     */
>>> -int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size);
>>> +int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size, int write_seq_header);
>>>
>>>    #endif /* AVFORMAT_AV1_H */
>>> diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
>>> index 38d9485288..5061961283 100644
>>> --- a/libavformat/matroskaenc.c
>>> +++ b/libavformat/matroskaenc.c
>>> @@ -1087,7 +1087,7 @@ static int mkv_write_native_codecprivate(AVFormatContext *s, AVIOContext *pb,
>>>        case AV_CODEC_ID_AV1:
>>>            if (par->extradata_size)
>>>                return ff_isom_write_av1c(dyn_cp, par->extradata,
>>> -                                      par->extradata_size);
>>> +                                      par->extradata_size, 1);
>>>            else
>>>                put_ebml_void(pb, 4 + 3);
>>>            break;
>>> @@ -2663,7 +2663,7 @@ static int mkv_check_new_extra_data(AVFormatContext *s, const AVPacket *pkt)
>>>                ret = avio_open_dyn_buf(&dyn_cp);
>>>                if (ret < 0)
>>>                    return ret;
>>> -            ff_isom_write_av1c(dyn_cp, side_data, side_data_size);
>>> +            ff_isom_write_av1c(dyn_cp, side_data, side_data_size, 1);
>>>                codecpriv_size = avio_get_dyn_buf(dyn_cp, &codecpriv);
>>>                if ((ret = dyn_cp->error) < 0 ||
>>>                    !codecpriv_size && (ret = AVERROR_INVALIDDATA)) {
>>> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
>>> index 4c868919ae..1a746a67fd 100644
>>> --- a/libavformat/movenc.c
>>> +++ b/libavformat/movenc.c
>>> @@ -1303,7 +1303,7 @@ static int mov_write_av1c_tag(AVIOContext *pb, MOVTrack *track)
>>>
>>>        avio_wb32(pb, 0);
>>>        ffio_wfourcc(pb, "av1C");
>>> -    ff_isom_write_av1c(pb, track->vos_data, track->vos_len);
>>> +    ff_isom_write_av1c(pb, track->vos_data, track->vos_len, 1);
>>>        return update_size(pb, pos);
>>>    }
>>>
>>
>> This patch no longer applies.
> 
> I have generated a new patch after sync'ing to the latest master. I
> did not notice any conflicts. Can you please check if the updated
> patch applies?

The new one does, yes. Thanks.

> 
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> 
> 
>
diff mbox series

Patch

diff --git a/libavformat/av1.c b/libavformat/av1.c
index 1fcfac2356..95ca7cc47f 100644
--- a/libavformat/av1.c
+++ b/libavformat/av1.c
@@ -361,7 +361,8 @@  int ff_av1_parse_seq_header(AV1SequenceParameters *seq, const uint8_t *buf, int
     return AVERROR_INVALIDDATA;
 }
 
-int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size)
+int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size,
+                       int write_seq_header)
 {
     AVIOContext *meta_pb;
     AV1SequenceParameters seq_params;
@@ -451,7 +452,9 @@  int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size)
     flush_put_bits(&pbc);
 
     avio_write(pb, header, sizeof(header));
-    avio_write(pb, seq, seq_size);
+    if (write_seq_header) {
+        avio_write(pb, seq, seq_size);
+    }
 
     meta_size = avio_get_dyn_buf(meta_pb, &meta);
     if (meta_size)
diff --git a/libavformat/av1.h b/libavformat/av1.h
index f57dabe986..a393fbb78f 100644
--- a/libavformat/av1.h
+++ b/libavformat/av1.h
@@ -96,9 +96,11 @@  int ff_av1_parse_seq_header(AV1SequenceParameters *seq, const uint8_t *buf, int
  * @param pb pointer to the AVIOContext where the av1C box shall be written
  * @param buf input data buffer
  * @param size size in bytes of the input data buffer
+ * @param write_seq_header If 1, Sequence Header OBU will be written inside the
+ *           av1C box. Otherwise, Sequence Header OBU will be omitted.
  *
  * @return >= 0 in case of success, a negative AVERROR code in case of failure
  */
-int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size);
+int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size, int write_seq_header);
 
 #endif /* AVFORMAT_AV1_H */
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 38d9485288..5061961283 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -1087,7 +1087,7 @@  static int mkv_write_native_codecprivate(AVFormatContext *s, AVIOContext *pb,
     case AV_CODEC_ID_AV1:
         if (par->extradata_size)
             return ff_isom_write_av1c(dyn_cp, par->extradata,
-                                      par->extradata_size);
+                                      par->extradata_size, 1);
         else
             put_ebml_void(pb, 4 + 3);
         break;
@@ -2663,7 +2663,7 @@  static int mkv_check_new_extra_data(AVFormatContext *s, const AVPacket *pkt)
             ret = avio_open_dyn_buf(&dyn_cp);
             if (ret < 0)
                 return ret;
-            ff_isom_write_av1c(dyn_cp, side_data, side_data_size);
+            ff_isom_write_av1c(dyn_cp, side_data, side_data_size, 1);
             codecpriv_size = avio_get_dyn_buf(dyn_cp, &codecpriv);
             if ((ret = dyn_cp->error) < 0 ||
                 !codecpriv_size && (ret = AVERROR_INVALIDDATA)) {
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 4c868919ae..1a746a67fd 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1303,7 +1303,7 @@  static int mov_write_av1c_tag(AVIOContext *pb, MOVTrack *track)
 
     avio_wb32(pb, 0);
     ffio_wfourcc(pb, "av1C");
-    ff_isom_write_av1c(pb, track->vos_data, track->vos_len);
+    ff_isom_write_av1c(pb, track->vos_data, track->vos_len, 1);
     return update_size(pb, pos);
 }