avformat/av1: Add a parameter to av1c to omit seq header

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>
This commit is contained in:
Vignesh Venkatasubramanian 2022-05-02 14:36:28 -07:00 committed by Gyan Doshi
parent ab05e9a7f2
commit 98ec4261fd
4 changed files with 11 additions and 6 deletions

View File

@ -395,7 +395,8 @@ int ff_av1_parse_seq_header(AV1SequenceParameters *seq, const uint8_t *buf, int
return is_av1c ? 0 : AVERROR_INVALIDDATA; return is_av1c ? 0 : 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; AVIOContext *meta_pb;
AV1SequenceParameters seq_params; AV1SequenceParameters seq_params;
@ -485,7 +486,9 @@ int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size)
flush_put_bits(&pbc); flush_put_bits(&pbc);
avio_write(pb, header, sizeof(header)); 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); meta_size = avio_get_dyn_buf(meta_pb, &meta);
if (meta_size) if (meta_size)

View File

@ -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 pb pointer to the AVIOContext where the av1C box shall be written
* @param buf input data buffer * @param buf input data buffer
* @param size size in bytes of the 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 * @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 */ #endif /* AVFORMAT_AV1_H */

View File

@ -1089,7 +1089,7 @@ static int mkv_write_native_codecprivate(AVFormatContext *s, AVIOContext *pb,
case AV_CODEC_ID_AV1: case AV_CODEC_ID_AV1:
if (par->extradata_size) if (par->extradata_size)
return ff_isom_write_av1c(dyn_cp, par->extradata, return ff_isom_write_av1c(dyn_cp, par->extradata,
par->extradata_size); par->extradata_size, 1);
else else
put_ebml_void(pb, 4 + 3); put_ebml_void(pb, 4 + 3);
break; break;
@ -2665,7 +2665,7 @@ static int mkv_check_new_extra_data(AVFormatContext *s, const AVPacket *pkt)
ret = avio_open_dyn_buf(&dyn_cp); ret = avio_open_dyn_buf(&dyn_cp);
if (ret < 0) if (ret < 0)
return ret; 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); codecpriv_size = avio_get_dyn_buf(dyn_cp, &codecpriv);
if ((ret = dyn_cp->error) < 0 || if ((ret = dyn_cp->error) < 0 ||
!codecpriv_size && (ret = AVERROR_INVALIDDATA)) { !codecpriv_size && (ret = AVERROR_INVALIDDATA)) {

View File

@ -1337,7 +1337,7 @@ static int mov_write_av1c_tag(AVIOContext *pb, MOVTrack *track)
avio_wb32(pb, 0); avio_wb32(pb, 0);
ffio_wfourcc(pb, "av1C"); 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); return update_size(pb, pos);
} }