v4l2codecs: Fix debug assertion in register functions
authorNicolas Dufresne <nicolas.dufresne@collabora.com>
Thu, 27 Jan 2022 16:49:53 +0000 (11:49 -0500)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 27 Jan 2022 18:53:41 +0000 (18:53 +0000)
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>

subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codech264dec.c
subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecmpeg2dec.c
subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecvp8dec.c
subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecvp9dec.c

index ce61d04..13505d4 100644 (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;
index 38c8fd4..e3a31da 100644 (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;
index a319741..6d547c5 100644 (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;
index fd635e8..19cd0a7 100644 (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;