From d89ede36298dd4985548c64ef177454b31e3c576 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Wed, 1 Nov 2023 10:16:27 -0400 Subject: [PATCH 50/68] v4l2codecs: encoders: Implement propose allocation For now, do not offer any pool since our buffer pool implementation is not complete. But at least advertise GstVideoMeta support in order to avoid upstream element having to normalize the strides. Upstream-Status: Pending --- sys/v4l2codecs/gstv4l2codech264enc.c | 15 +++++++++++++++ sys/v4l2codecs/gstv4l2codecvp8enc.c | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/sys/v4l2codecs/gstv4l2codech264enc.c b/sys/v4l2codecs/gstv4l2codech264enc.c index 9f1b994..070c51a 100644 --- a/sys/v4l2codecs/gstv4l2codech264enc.c +++ b/sys/v4l2codecs/gstv4l2codech264enc.c @@ -265,6 +265,19 @@ gst_v4l2_codec_h264_enc_getcaps (GstVideoEncoder * encoder, GstCaps * filter) return result; } +static gboolean +gst_v4l2_codec_h264_enc_propose_allocation (GstVideoEncoder * encoder, + GstQuery * query) +{ + GstV4l2CodecH264Enc *self = GST_V4L2_CODEC_H264_ENC (encoder); + + gst_query_add_allocation_pool (query, NULL, self->vinfo.size, 2, 0); + gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL); + + return GST_VIDEO_ENCODER_CLASS (parent_class)->propose_allocation (encoder, + query); +} + static gboolean gst_v4l2_codec_h264_enc_buffers_allocation (GstVideoEncoder * encoder) { @@ -1078,6 +1091,8 @@ gst_v4l2_codec_h264_enc_subclass_init (GstV4l2CodecH264EncClass * klass, encoder_class->sink_event = GST_DEBUG_FUNCPTR (gst_v4l2_codec_h264_enc_sink_event); encoder_class->getcaps = GST_DEBUG_FUNCPTR (gst_v4l2_codec_h264_enc_getcaps); + encoder_class->propose_allocation = + GST_DEBUG_FUNCPTR (gst_v4l2_codec_h264_enc_propose_allocation); h264encoder_class->encode_frame = GST_DEBUG_FUNCPTR (gst_v4l2_codec_h264_enc_encode_frame); diff --git a/sys/v4l2codecs/gstv4l2codecvp8enc.c b/sys/v4l2codecs/gstv4l2codecvp8enc.c index 2d476b3..24e8540 100644 --- a/sys/v4l2codecs/gstv4l2codecvp8enc.c +++ b/sys/v4l2codecs/gstv4l2codecvp8enc.c @@ -235,6 +235,19 @@ gst_v4l2_codec_vp8_enc_getcaps (GstVideoEncoder * encoder, GstCaps * filter) return result; } +static gboolean +gst_v4l2_codec_vp8_enc_propose_allocation (GstVideoEncoder * encoder, + GstQuery * query) +{ + GstV4l2CodecVp8Enc *self = GST_V4L2_CODEC_VP8_ENC (encoder); + + gst_query_add_allocation_pool (query, NULL, self->vinfo.size, 2, 0); + gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL); + + return GST_VIDEO_ENCODER_CLASS (parent_class)->propose_allocation (encoder, + query); +} + static gboolean gst_v4l2_codec_vp8_enc_buffers_allocation (GstVideoEncoder * encoder) { @@ -689,6 +702,8 @@ gst_v4l2_codec_vp8_enc_subclass_init (GstV4l2CodecVp8EncClass * klass, encoder_class->sink_event = GST_DEBUG_FUNCPTR (gst_v4l2_codec_vp8_enc_sink_event); encoder_class->getcaps = GST_DEBUG_FUNCPTR (gst_v4l2_codec_vp8_enc_getcaps); + encoder_class->propose_allocation = + GST_DEBUG_FUNCPTR (gst_v4l2_codec_vp8_enc_propose_allocation); vp8encoder_class->encode_frame = GST_DEBUG_FUNCPTR (gst_v4l2_codec_vp8_enc_encode_frame); -- 2.25.1