From d7363bd838572a9c638672723a2d621dffc4e4dc Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Thu, 27 Jan 2022 11:49:53 -0500 Subject: [PATCH] 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: --- .../gst-plugins-bad/sys/v4l2codecs/gstv4l2codech264dec.c | 10 ++++++---- .../gst-plugins-bad/sys/v4l2codecs/gstv4l2codecmpeg2dec.c | 10 ++++++---- .../gst-plugins-bad/sys/v4l2codecs/gstv4l2codecvp8dec.c | 10 ++++++---- .../gst-plugins-bad/sys/v4l2codecs/gstv4l2codecvp9dec.c | 11 ++++++----- 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codech264dec.c b/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codech264dec.c index ce61d04..13505d4 100644 --- a/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codech264dec.c +++ b/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codech264dec.c @@ -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; diff --git a/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecmpeg2dec.c b/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecmpeg2dec.c index 38c8fd4..e3a31da 100644 --- a/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecmpeg2dec.c +++ b/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecmpeg2dec.c @@ -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; diff --git a/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecvp8dec.c b/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecvp8dec.c index a319741..6d547c5 100644 --- a/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecvp8dec.c +++ b/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecvp8dec.c @@ -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; diff --git a/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecvp9dec.c b/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecvp9dec.c index fd635e8..19cd0a7 100644 --- a/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecvp9dec.c +++ b/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecvp9dec.c @@ -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; -- 2.7.4