From 7dbb6681a32dedc890bba1ba17ddd714e35031b0 Mon Sep 17 00:00:00 2001 From: Matthieu Bouron Date: Mon, 20 Apr 2015 13:46:58 +0200 Subject: [PATCH] androidmedia: Only allow GL output if the decoder has unknown color formats If GST_AMC_IGNORE_UNKNOWN_COLOR_FORMATS is set to yes, non-GL output is still allowed. https://bugzilla.gnome.org/show_bug.cgi?id=731204 --- sys/androidmedia/gstamc.c | 14 ++++++++------ sys/androidmedia/gstamc.h | 1 + sys/androidmedia/gstamcvideodec.c | 14 +++++++++++++- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/sys/androidmedia/gstamc.c b/sys/androidmedia/gstamc.c index da1063a319..f333820789 100644 --- a/sys/androidmedia/gstamc.c +++ b/sys/androidmedia/gstamc.c @@ -1567,6 +1567,7 @@ scan_codecs (GstPlugin * plugin) goto next_codec; } gst_codec_info->is_encoder = is_encoder; + gst_codec_info->gl_output_only = FALSE; supported_types = (*env)->CallObjectMethod (env, codec_info, get_supported_types_id); @@ -1710,12 +1711,13 @@ scan_codecs (GstPlugin * plugin) goto next_supported_type; } - if (!ignore_unknown_color_formats - && !accepted_color_formats (gst_codec_type, is_encoder)) { - GST_ERROR ("%s %s has unknown color formats, ignoring", - gst_codec_type->mime, is_encoder ? "encoder" : "decoder"); - valid_codec = FALSE; - goto next_supported_type; + if (!accepted_color_formats (gst_codec_type, is_encoder)) { + if (!ignore_unknown_color_formats) { + gst_codec_info->gl_output_only = TRUE; + GST_WARNING + ("%s %s has unknown color formats, only direct rendering will be supported", + gst_codec_type->mime, is_encoder ? "encoder" : "decoder"); + } } } diff --git a/sys/androidmedia/gstamc.h b/sys/androidmedia/gstamc.h index 7b0cd9b3ad..a6406166b5 100644 --- a/sys/androidmedia/gstamc.h +++ b/sys/androidmedia/gstamc.h @@ -53,6 +53,7 @@ struct _GstAmcCodecType { struct _GstAmcCodecInfo { gchar *name; gboolean is_encoder; + gboolean gl_output_only; GstAmcCodecType *supported_types; gint n_supported_types; }; diff --git a/sys/androidmedia/gstamcvideodec.c b/sys/androidmedia/gstamcvideodec.c index 70371ddbba..58a438601f 100644 --- a/sys/androidmedia/gstamcvideodec.c +++ b/sys/androidmedia/gstamcvideodec.c @@ -230,7 +230,11 @@ gst_amc_video_dec_base_init (gpointer g_class) gst_caps_from_string (GST_VIDEO_CAPS_MAKE_WITH_FEATURES (GST_CAPS_FEATURE_MEMORY_GL_MEMORY, "RGBA")); - gst_caps_append (all_src_caps, src_caps); + if (codec_info->gl_output_only) { + gst_caps_unref (src_caps); + } else { + gst_caps_append (all_src_caps, src_caps); + } /* Add pad templates */ templ = @@ -1224,6 +1228,7 @@ gst_amc_video_dec_set_format (GstVideoDecoder * decoder, GstVideoCodecState * state) { GstAmcVideoDec *self; + GstAmcVideoDecClass *klass; GstAmcFormat *format; const gchar *mime; gboolean is_format_change = FALSE; @@ -1235,6 +1240,7 @@ gst_amc_video_dec_set_format (GstVideoDecoder * decoder, jobject jsurface = NULL; self = GST_AMC_VIDEO_DEC (decoder); + klass = GST_AMC_VIDEO_DEC_GET_CLASS (self); GST_DEBUG_OBJECT (self, "Setting new caps %" GST_PTR_FORMAT, state->caps); @@ -1414,6 +1420,12 @@ gst_amc_video_dec_set_format (GstVideoDecoder * decoder, GST_INFO_OBJECT (self, "GL output: %s", self->downstream_supports_gl ? "enabled" : "disabled"); + if (klass->codec_info->gl_output_only && !self->downstream_supports_gl) { + GST_ERROR_OBJECT (self, + "Codec only supports GL output but downstream does not"); + return FALSE; + } + if (self->downstream_supports_gl && self->surface) { jsurface = self->surface->jobject; } else if (self->downstream_supports_gl && !self->surface) {