aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-multimedia/gstreamer/gstreamer1.0-omx/0004-omxvideodec-change-supported-color-formats-list-crea.patch
blob: 1f208711278649b9c76831ec5dd28e539f6d91c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
From 92bf075e1ce4b2687acc84f56ffbfff17883069e Mon Sep 17 00:00:00 2001
From: Kazunori Kobayashi <kkobayas@igel.co.jp>
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 (&param);
   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, &param);
+  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, &param);
-
-    /* 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, &param);
+  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