aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2022-02-26 20:30:45 -0300
committerJames Almer <jamrial@gmail.com>2022-02-28 09:08:27 -0300
commit76e10325fc65b816193b4acb9bfda174262ff6ba (patch)
treeb711f72bbe97a8556247c62e9ebb1c99443fc506
parentb6c7f82db75d2c77df2312b92a048a9ae0c5e86a (diff)
downloadffmpeg-76e10325fc65b816193b4acb9bfda174262ff6ba.tar.gz
avformat/av1: support av1C extradata in ff_av1_parse_seq_header()
Fixes dash manifest creation for av1 streams with av1C formatted extradata. Signed-off-by: James Almer <jamrial@gmail.com>
-rw-r--r--libavformat/av1.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/libavformat/av1.c b/libavformat/av1.c
index 1fcfac2356..7771c09b4a 100644
--- a/libavformat/av1.c
+++ b/libavformat/av1.c
@@ -335,10 +335,43 @@ int ff_av1_parse_seq_header(AV1SequenceParameters *seq, const uint8_t *buf, int
{
int64_t obu_size;
int start_pos, type, temporal_id, spatial_id;
+ int is_av1c;
if (size <= 0)
return AVERROR_INVALIDDATA;
+ is_av1c = !!(buf[0] & 0x80);
+ if (is_av1c) {
+ GetBitContext gb;
+ int ret, version = buf[0] & 0x7F;
+
+ if (version != 1 || size < 4)
+ return AVERROR_INVALIDDATA;
+
+ ret = init_get_bits8(&gb, buf, 4);
+ if (ret < 0)
+ return ret;
+
+ memset(seq, 0, sizeof(*seq));
+
+ skip_bits(&gb, 8);
+ seq->profile = get_bits(&gb, 3);
+ seq->level = get_bits(&gb, 5);
+ seq->tier = get_bits(&gb, 1);
+ seq->bitdepth = get_bits(&gb, 1) * 2 + 8;
+ seq->bitdepth += get_bits(&gb, 1) * 2;
+ seq->monochrome = get_bits(&gb, 1);
+ seq->chroma_subsampling_x = get_bits(&gb, 1);
+ seq->chroma_subsampling_y = get_bits(&gb, 1);
+ seq->chroma_sample_position = get_bits(&gb, 2);
+ seq->color_primaries = AVCOL_PRI_UNSPECIFIED;
+ seq->transfer_characteristics = AVCOL_TRC_UNSPECIFIED;
+ seq->matrix_coefficients = AVCOL_SPC_UNSPECIFIED;
+
+ size -= 4;
+ buf += 4;
+ }
+
while (size > 0) {
int len = parse_obu_header(buf, size, &obu_size, &start_pos,
&type, &temporal_id, &spatial_id);
@@ -358,7 +391,7 @@ int ff_av1_parse_seq_header(AV1SequenceParameters *seq, const uint8_t *buf, int
buf += len;
}
- return AVERROR_INVALIDDATA;
+ return is_av1c ? 0 : AVERROR_INVALIDDATA;
}
int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size)