Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: James Almer <jamrial@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH] avformat/av1: support av1C extradata in ff_av1_parse_seq_header()
Date: Sat, 26 Feb 2022 20:37:30 -0300
Message-ID: <20220226233730.4315-1-jamrial@gmail.com> (raw)

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".

                 reply	other threads:[~2022-02-26 23:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220226233730.4315-1-jamrial@gmail.com \
    --to=jamrial@gmail.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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