* [FFmpeg-devel] [PATCH] avformat/av1: support av1C extradata in ff_av1_parse_seq_header()
@ 2022-02-26 23:37 James Almer
0 siblings, 0 replies; only message in thread
From: James Almer @ 2022-02-26 23:37 UTC (permalink / raw)
To: ffmpeg-devel
Fixes dash manifest creation for av1 streams with av1C formatted extradata.
Signed-off-by: James Almer <jamrial@gmail.com>
---
libavformat/av1.c | 35 ++++++++++++++++++++++++++++++++++-
1 file changed, 34 insertions(+), 1 deletion(-)
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)
--
2.35.1
_______________________________________________
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".
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-02-26 23:38 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-26 23:37 [FFmpeg-devel] [PATCH] avformat/av1: support av1C extradata in ff_av1_parse_seq_header() James Almer
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git