rav1enc: Put container sequence header into the caps

This commit is contained in:
Sebastian Dröge 2022-02-08 12:18:48 +02:00
parent 22ae31bfcb
commit 93bfa4d37a

View file

@ -93,6 +93,13 @@ enum Context {
} }
impl Context { impl Context {
fn container_sequence_header(&self) -> Vec<u8> {
match self {
Context::Eight(ref context) => context.container_sequence_header(),
Context::Sixteen(ref context) => context.container_sequence_header(),
}
}
fn receive_packet( fn receive_packet(
&mut self, &mut self,
) -> Result<(data::FrameType, u64, u32, Vec<u8>), data::EncoderStatus> { ) -> Result<(data::FrameType, u64, u32, Vec<u8>), data::EncoderStatus> {
@ -840,8 +847,8 @@ impl VideoEncoderImpl for Rav1Enc {
.with_threads(settings.threads); .with_threads(settings.threads);
// TODO: RateControlConfig // TODO: RateControlConfig
*self.state.lock().unwrap() = Some(State { let context =
context: if video_info.format_info().depth()[0] > 8 { if video_info.format_info().depth()[0] > 8 {
Context::Sixteen(cfg.new_context().map_err(|err| { Context::Sixteen(cfg.new_context().map_err(|err| {
gst::loggable_error!(CAT, "Failed to create context: {:?}", 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| { Context::Eight(cfg.new_context().map_err(|err| {
gst::loggable_error!(CAT, "Failed to create context: {:?}", 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, video_info,
}); });
@ -858,6 +870,7 @@ impl VideoEncoderImpl for Rav1Enc {
gst::Caps::builder("video/x-av1") gst::Caps::builder("video/x-av1")
.field("stream-format", "obu-stream") .field("stream-format", "obu-stream")
.field("alignment", "tu") .field("alignment", "tu")
.field("codec_data", container_sequence_header)
.build(), .build(),
Some(state), Some(state),
) )