From 92bf075e1ce4b2687acc84f56ffbfff17883069e Mon Sep 17 00:00:00 2001 From: Kazunori Kobayashi Date: Thu, 6 Jun 2013 11:31:27 +0900 Subject: [PATCH 04/14] omxvideodec: change supported color formats list creation To create supported color formats list for caps negotiation, this change tries to set each color format that is prepared in a list beforehand and determines which color formats are supported by the component. The more components can be dealt with by this support. NV12 color format is put at the top of the list declared as a constant so that the caps negotiation gives top priority to this color format. --- omx/gstomxvideodec.c | 84 +++++++++++++++++++++++----------------------------- 1 file changed, 37 insertions(+), 47 deletions(-) diff --git a/omx/gstomxvideodec.c b/omx/gstomxvideodec.c index df6362b..62ee5c5 100644 --- a/omx/gstomxvideodec.c +++ b/omx/gstomxvideodec.c @@ -1793,63 +1793,53 @@ static GList * gst_omx_video_dec_get_supported_colorformats (GstOMXVideoDec * self) { GstOMXPort *port = self->dec_out_port; - GstVideoCodecState *state = self->input_state; OMX_VIDEO_PARAM_PORTFORMATTYPE param; OMX_ERRORTYPE err; GList *negotiation_map = NULL; - gint old_index; + gint i; + OMX_COLOR_FORMATTYPE format_org; + VideoNegotiationMap *m; + const VideoNegotiationMap format_list[] = { + {GST_VIDEO_FORMAT_NV12, OMX_COLOR_FormatYUV420SemiPlanar}, + {GST_VIDEO_FORMAT_I420, OMX_COLOR_FormatYUV420Planar}, + {GST_VIDEO_FORMAT_I420, OMX_COLOR_FormatYUV420PackedPlanar}, + }; GST_OMX_INIT_STRUCT (¶m); param.nPortIndex = port->index; - param.nIndex = 0; - if (!state || state->info.fps_n == 0) - param.xFramerate = 0; - else - param.xFramerate = (state->info.fps_n << 16) / (state->info.fps_d); - old_index = -1; - do { - VideoNegotiationMap *m; + err = gst_omx_component_get_parameter (self->dec, + OMX_IndexParamVideoPortFormat, ¶m); + if (err != OMX_ErrorNone) { + GST_ERROR_OBJECT (self, + "Failed to getting video port format (err info: %s (0x%08x))", + gst_omx_error_to_string (err), err); + return NULL; + } + /* temporary save original format type */ + format_org = param.eColorFormat; - err = - gst_omx_component_get_parameter (self->dec, + for (i = 0; i < sizeof (format_list) / sizeof (VideoNegotiationMap); i++) { + param.eColorFormat = format_list[i].type; + err = gst_omx_component_set_parameter (self->dec, OMX_IndexParamVideoPortFormat, ¶m); - - /* FIXME: Workaround for Bellagio that simply always - * returns the same value regardless of nIndex and - * never returns OMX_ErrorNoMore - */ - if (old_index == param.nIndex) - break; - - if (err == OMX_ErrorNone || err == OMX_ErrorNoMore) { - switch (param.eColorFormat) { - case OMX_COLOR_FormatYUV420Planar: - case OMX_COLOR_FormatYUV420PackedPlanar: - m = g_slice_new (VideoNegotiationMap); - m->format = GST_VIDEO_FORMAT_I420; - m->type = param.eColorFormat; - negotiation_map = g_list_append (negotiation_map, m); - GST_DEBUG_OBJECT (self, "Component supports I420 (%d) at index %d", - param.eColorFormat, param.nIndex); - break; - case OMX_COLOR_FormatYUV420SemiPlanar: - m = g_slice_new (VideoNegotiationMap); - m->format = GST_VIDEO_FORMAT_NV12; - m->type = param.eColorFormat; - negotiation_map = g_list_append (negotiation_map, m); - GST_DEBUG_OBJECT (self, "Component supports NV12 (%d) at index %d", - param.eColorFormat, param.nIndex); - break; - default: - GST_DEBUG_OBJECT (self, - "Component supports unsupported color format %d at index %d", - param.eColorFormat, param.nIndex); - break; - } + if (err == OMX_ErrorNone) { + m = g_slice_new (VideoNegotiationMap); + m->format = format_list[i].format; + m->type = format_list[i].type; + negotiation_map = g_list_append (negotiation_map, m); + GST_DEBUG_OBJECT (self, "Component supports (%d)", param.eColorFormat); } - old_index = param.nIndex++; - } while (err == OMX_ErrorNone); + } + + /* restore setting */ + param.eColorFormat = format_org; + err = gst_omx_component_set_parameter (self->dec, + OMX_IndexParamVideoPortFormat, ¶m); + if (err != OMX_ErrorNone) + GST_ERROR_OBJECT (self, + "Failed to seetting video port format (err info: %s (0x%08x))", + gst_omx_error_to_string (err), err); return negotiation_map; } -- 1.8.1.2