From 93bfa4d37abbbd7f01e01fb8088e2b6f19e5ec47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 8 Feb 2022 12:18:48 +0200 Subject: [PATCH] rav1enc: Put container sequence header into the caps --- video/rav1e/src/rav1enc/imp.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/video/rav1e/src/rav1enc/imp.rs b/video/rav1e/src/rav1enc/imp.rs index ca7e5b75..7c832ce1 100644 --- a/video/rav1e/src/rav1enc/imp.rs +++ b/video/rav1e/src/rav1enc/imp.rs @@ -93,6 +93,13 @@ enum Context { } impl Context { + fn container_sequence_header(&self) -> Vec { + match self { + Context::Eight(ref context) => context.container_sequence_header(), + Context::Sixteen(ref context) => context.container_sequence_header(), + } + } + fn receive_packet( &mut self, ) -> Result<(data::FrameType, u64, u32, Vec), data::EncoderStatus> { @@ -840,8 +847,8 @@ impl VideoEncoderImpl for Rav1Enc { .with_threads(settings.threads); // TODO: RateControlConfig - *self.state.lock().unwrap() = Some(State { - context: if video_info.format_info().depth()[0] > 8 { + let context = + if video_info.format_info().depth()[0] > 8 { Context::Sixteen(cfg.new_context().map_err(|err| { gst::loggable_error!(CAT, "Failed to create context: {:?}", err) })?) @@ -849,7 +856,12 @@ impl VideoEncoderImpl for Rav1Enc { Context::Eight(cfg.new_context().map_err(|err| { gst::loggable_error!(CAT, "Failed to create context: {:?}", err) })?) - }, + }; + let container_sequence_header = + gst::Buffer::from_mut_slice(context.container_sequence_header()); + + *self.state.lock().unwrap() = Some(State { + context, video_info, }); @@ -858,6 +870,7 @@ impl VideoEncoderImpl for Rav1Enc { gst::Caps::builder("video/x-av1") .field("stream-format", "obu-stream") .field("alignment", "tu") + .field("codec_data", container_sequence_header) .build(), Some(state), )