From 2e25f166fcfbc704d3ad400cde7bc3c75662f4b9 Mon Sep 17 00:00:00 2001 From: Arun Raghavan Date: Mon, 20 Mar 2017 22:19:47 +0530 Subject: [PATCH] avvidenc: Classify image encoders with "Image" instead of "Video" This allows gst_video_convert_sample*() to work with codecs for which we have libav encoders (such as BMP). https://bugzilla.gnome.org/show_bug.cgi?id=780317 --- ext/libav/gstavcodecmap.c | 24 ++++++++++++++++++++++++ ext/libav/gstavcodecmap.h | 6 ++++++ ext/libav/gstavvidenc.c | 6 +++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/ext/libav/gstavcodecmap.c b/ext/libav/gstavcodecmap.c index f6da86fc8f..35a2ca06f3 100644 --- a/ext/libav/gstavcodecmap.c +++ b/ext/libav/gstavcodecmap.c @@ -721,6 +721,30 @@ gst_ff_aud_caps_new (AVCodecContext * context, AVCodec * codec, return caps; } +/* Check if the given codec ID is an image format -- for now this is just + * anything whose caps is image/... */ +gboolean +gst_ffmpeg_codecid_is_image (enum AVCodecID codec_id) +{ + switch (codec_id) { + case AV_CODEC_ID_MJPEG: + case AV_CODEC_ID_LJPEG: + case AV_CODEC_ID_GIF: + case AV_CODEC_ID_PPM: + case AV_CODEC_ID_PBM: + case AV_CODEC_ID_PCX: + case AV_CODEC_ID_SGI: + case AV_CODEC_ID_TARGA: + case AV_CODEC_ID_TIFF: + case AV_CODEC_ID_SUNRAST: + case AV_CODEC_ID_BMP: + return TRUE; + + default: + return FALSE; + } +} + /* Convert a FFMPEG codec ID and optional AVCodecContext * to a GstCaps. If the context is ommitted, no fixed values * for video/audio size will be included in the GstCaps diff --git a/ext/libav/gstavcodecmap.h b/ext/libav/gstavcodecmap.h index 486a0d5dfc..9575e7789a 100644 --- a/ext/libav/gstavcodecmap.h +++ b/ext/libav/gstavcodecmap.h @@ -67,6 +67,12 @@ gst_ffmpeg_compliance_get_type (void); #define GST_TYPE_FFMPEG_COMPLIANCE (gst_ffmpeg_compliance_get_type ()) #define FFMPEG_DEFAULT_COMPLIANCE GST_FFMPEG_NORMAL +/* + * _codecid_is_image() returns TRUE for image formats + */ +gboolean +gst_ffmpeg_codecid_is_image (enum AVCodecID codec_id); + /* * _codecid_to_caps () gets the GstCaps that belongs to * a certain CodecID for a pad with compressed data. diff --git a/ext/libav/gstavvidenc.c b/ext/libav/gstavvidenc.c index f241ec3a4c..7f28dfb01d 100644 --- a/ext/libav/gstavvidenc.c +++ b/ext/libav/gstavvidenc.c @@ -126,6 +126,7 @@ gst_ffmpegvidenc_base_init (GstFFMpegVidEncClass * klass) GstPadTemplate *srctempl = NULL, *sinktempl = NULL; GstCaps *srccaps = NULL, *sinkcaps = NULL; gchar *longname, *description; + const gchar *klass; in_plugin = (AVCodec *) g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass), @@ -135,8 +136,11 @@ gst_ffmpegvidenc_base_init (GstFFMpegVidEncClass * klass) /* construct the element details struct */ longname = g_strdup_printf ("libav %s encoder", in_plugin->long_name); description = g_strdup_printf ("libav %s encoder", in_plugin->name); + klass = + gst_ffmpeg_codecid_is_image (in_plugin->id) ? "Codec/Encoder/Image" : + "Codec/Encoder/Video"; gst_element_class_set_metadata (element_class, longname, - "Codec/Encoder/Video", description, + klass, description, "Wim Taymans , " "Ronald Bultje "); g_free (longname);