v4l2codecs: Fix debug assertion in register functions

As now, we warn if the decoder have no support src pixel format, but that
warning is called before the type (hence the debug category) is initialized.
Fix this by moving the debug category init out of the type initialization,
into the register funcitons.

This will fix an assertion that occures in the register function and allow
relevant log to be seen by the users.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1588>
This commit is contained in:
Nicolas Dufresne 2022-01-27 11:49:53 -05:00 committed by GStreamer Marge Bot
parent bea8cba5e6
commit d7363bd838
4 changed files with 24 additions and 17 deletions

View file

@ -95,10 +95,9 @@ struct _GstV4l2CodecH264Dec
GstMapInfo bitstream_map;
};
G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GstV4l2CodecH264Dec,
gst_v4l2_codec_h264_dec, GST_TYPE_H264_DECODER,
GST_DEBUG_CATEGORY_INIT (v4l2_h264dec_debug, "v4l2codecs-h264dec", 0,
"V4L2 stateless h264 decoder"));
G_DEFINE_ABSTRACT_TYPE (GstV4l2CodecH264Dec, gst_v4l2_codec_h264_dec,
GST_TYPE_H264_DECODER);
#define parent_class gst_v4l2_codec_h264_dec_parent_class
static gboolean
@ -1522,6 +1521,9 @@ gst_v4l2_codec_h264_dec_register (GstPlugin * plugin, GstV4l2Decoder * decoder,
{
GstCaps *src_caps;
GST_DEBUG_CATEGORY_INIT (v4l2_h264dec_debug, "v4l2codecs-h264dec", 0,
"V4L2 stateless h264 decoder");
if (!gst_v4l2_decoder_set_sink_fmt (decoder, V4L2_PIX_FMT_H264_SLICE,
320, 240, 8))
return;

View file

@ -92,10 +92,9 @@ struct _GstV4l2CodecMpeg2Dec
gboolean copy_frames;
};
G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GstV4l2CodecMpeg2Dec,
gst_v4l2_codec_mpeg2_dec, GST_TYPE_MPEG2_DECODER,
GST_DEBUG_CATEGORY_INIT (v4l2_mpeg2dec_debug, "v4l2codecs-mpeg2dec", 0,
"V4L2 stateless mpeg2 decoder"));
G_DEFINE_ABSTRACT_TYPE (GstV4l2CodecMpeg2Dec, gst_v4l2_codec_mpeg2_dec,
GST_TYPE_MPEG2_DECODER);
#define parent_class gst_v4l2_codec_mpeg2_dec_parent_class
static guint
@ -1054,6 +1053,9 @@ gst_v4l2_codec_mpeg2_dec_register (GstPlugin * plugin, GstV4l2Decoder * decoder,
{
GstCaps *src_caps;
GST_DEBUG_CATEGORY_INIT (v4l2_mpeg2dec_debug, "v4l2codecs-mpeg2dec", 0,
"V4L2 stateless mpeg2 decoder");
if (!gst_v4l2_decoder_set_sink_fmt (decoder, V4L2_PIX_FMT_MPEG2_SLICE,
320, 240, 8))
return;

View file

@ -82,10 +82,9 @@ struct _GstV4l2CodecVp8Dec
GstMapInfo bitstream_map;
};
G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GstV4l2CodecVp8Dec,
gst_v4l2_codec_vp8_dec, GST_TYPE_VP8_DECODER,
GST_DEBUG_CATEGORY_INIT (v4l2_vp8dec_debug, "v4l2codecs-vp8dec", 0,
"V4L2 stateless VP8 decoder"));
G_DEFINE_ABSTRACT_TYPE (GstV4l2CodecVp8Dec, gst_v4l2_codec_vp8_dec,
GST_TYPE_VP8_DECODER);
#define parent_class gst_v4l2_codec_vp8_dec_parent_class
static guint
@ -933,6 +932,9 @@ gst_v4l2_codec_vp8_dec_register (GstPlugin * plugin, GstV4l2Decoder * decoder,
gchar *element_name;
GstCaps *src_caps, *alpha_caps;
GST_DEBUG_CATEGORY_INIT (v4l2_vp8dec_debug, "v4l2codecs-vp8dec", 0,
"V4L2 stateless VP8 decoder");
if (!gst_v4l2_decoder_set_sink_fmt (decoder, V4L2_PIX_FMT_VP8_FRAME,
320, 240, 8))
return;

View file

@ -91,12 +91,10 @@ struct _GstV4l2CodecVp9Dec
guint subsampling_y;
};
#define parent_class gst_v4l2_codec_vp9_dec_parent_class
G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GstV4l2CodecVp9Dec,
gst_v4l2_codec_vp9_dec, GST_TYPE_VP9_DECODER,
GST_DEBUG_CATEGORY_INIT (v4l2_vp9dec_debug, "v4l2codecs-vp9dec", 0,
"V4L2 stateless VP9 decoder"));
G_DEFINE_ABSTRACT_TYPE (GstV4l2CodecVp9Dec, gst_v4l2_codec_vp9_dec,
GST_TYPE_VP9_DECODER);
#define parent_class gst_v4l2_codec_vp9_dec_parent_class
static guint
gst_v4l2_codec_vp9_dec_get_preferred_output_delay (GstVp9Decoder * decoder,
@ -1131,6 +1129,9 @@ gst_v4l2_codec_vp9_dec_register (GstPlugin * plugin, GstV4l2Decoder * decoder,
gchar *element_name;
GstCaps *src_caps, *alpha_caps;
GST_DEBUG_CATEGORY_INIT (v4l2_vp9dec_debug, "v4l2codecs-vp9dec", 0,
"V4L2 stateless VP9 decoder");
if (!gst_v4l2_decoder_set_sink_fmt (decoder, V4L2_PIX_FMT_VP9_FRAME,
320, 240, 8))
return;