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
127
128
129
130
131
132
133
134
135
136
137
|
From d32d532b62595b17dd88ea4e2e424cb11337118a Mon Sep 17 00:00:00 2001
From: Julian Scheel <julian@jusst.de>
Date: Thu, 5 Sep 2013 16:10:32 +0200
Subject: [PATCH] omxil: rpi: Fetch pixel aspect ratio from decoder.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The broadcom omx implementation has a vendor extension to fetch pixel aspect
information from the decoder. Use this to pass proper aspect information with
the pictures.
Signed-off-by: Julian Scheel <julian@jusst.de>
Signed-off-by: Martin Storsjö <martin@martin.st>
---
modules/codec/omxil/omxil.c | 63 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 63 insertions(+)
diff --git a/modules/codec/omxil/omxil.c b/modules/codec/omxil/omxil.c
index 59679f6..0fafedf 100644
--- a/modules/codec/omxil/omxil.c
+++ b/modules/codec/omxil/omxil.c
@@ -39,6 +39,7 @@
#include "omxil.h"
#include "omxil_core.h"
+#include "OMX_Broadcom.h"
#ifndef NDEBUG
# define OMXIL_EXTRA_DEBUG
@@ -46,6 +47,13 @@
#define SENTINEL_FLAG 0x10000
+/* Defined in the broadcom version of OMX_Index.h */
+#define OMX_IndexConfigRequestCallback 0x7f000063
+#define OMX_IndexParamBrcmPixelAspectRatio 0x7f00004d
+
+/* Defined in the broadcom version of OMX_Core.h */
+#define OMX_EventParamOrConfigChanged 0x7F000001
+
/*****************************************************************************
* Local prototypes
*****************************************************************************/
@@ -345,6 +353,34 @@ static OMX_ERRORTYPE SetPortDefinition(decoder_t *p_dec, OmxPort *p_port,
return omx_error;
}
+
+/*****************************************************************************
+ * UpdatePixelAspect: Update vlc pixel aspect based on the aspect reported on
+ * the omx port - NOTE: Broadcom specific
+ *****************************************************************************/
+static OMX_ERRORTYPE UpdatePixelAspect(decoder_t *p_dec)
+{
+ decoder_sys_t *p_sys = p_dec->p_sys;
+ OMX_CONFIG_POINTTYPE pixel_aspect;
+ OMX_INIT_STRUCTURE(pixel_aspect);
+ OMX_ERRORTYPE omx_err;
+
+ if (strncmp(p_sys->psz_component, "OMX.broadcom.", 13))
+ return OMX_ErrorNotImplemented;
+
+ pixel_aspect.nPortIndex = p_sys->out.i_port_index;
+ omx_err = OMX_GetParameter(p_sys->omx_handle,
+ OMX_IndexParamBrcmPixelAspectRatio, &pixel_aspect);
+ if (omx_err != OMX_ErrorNone) {
+ msg_Warn(p_dec, "Failed to retrieve aspect ratio");
+ } else {
+ p_dec->fmt_out.video.i_sar_num = pixel_aspect.nX;
+ p_dec->fmt_out.video.i_sar_den = pixel_aspect.nY;
+ }
+
+ return omx_err;
+}
+
/*****************************************************************************
* GetPortDefinition: set vlc format based on the definition of the omx port
*****************************************************************************/
@@ -430,6 +466,7 @@ static OMX_ERRORTYPE GetPortDefinition(decoder_t *p_dec, OmxPort *p_port,
def->format.video.nStride = p_port->i_frame_stride;
#endif
p_port->i_frame_stride = def->format.video.nStride;
+ UpdatePixelAspect(p_dec);
break;
case AUDIO_ES:
@@ -683,6 +720,23 @@ static OMX_ERRORTYPE InitialiseComponent(decoder_t *p_dec,
}
}
+ if(!strncmp(p_sys->psz_component, "OMX.broadcom.", 13))
+ {
+ OMX_CONFIG_REQUESTCALLBACKTYPE notifications;
+ OMX_INIT_STRUCTURE(notifications);
+
+ notifications.nPortIndex = p_sys->out.i_port_index;
+ notifications.nIndex = OMX_IndexParamBrcmPixelAspectRatio;
+ notifications.bEnable = OMX_TRUE;
+
+ omx_error = OMX_SetParameter(omx_handle,
+ OMX_IndexConfigRequestCallback, ¬ifications);
+ if (omx_error == OMX_ErrorNone)
+ msg_Dbg(p_dec, "Enabled aspect ratio notifications");
+ else
+ msg_Dbg(p_dec, "Could not enable aspect ratio notifications");
+ }
+
/* Set port definitions */
for(i = 0; i < p_sys->ports; i++)
{
@@ -796,6 +850,12 @@ static int OpenGeneric( vlc_object_t *p_this, bool b_encode )
p_dec->fmt_out.video = p_dec->fmt_in.video;
p_dec->fmt_out.audio = p_dec->fmt_in.audio;
p_dec->fmt_out.i_codec = 0;
+
+ /* set default aspect of 1, if parser did not set it */
+ if (p_dec->fmt_out.video.i_sar_num == 0)
+ p_dec->fmt_out.video.i_sar_num = 1;
+ if (p_dec->fmt_out.video.i_sar_den == 0)
+ p_dec->fmt_out.video.i_sar_den = 1;
}
p_sys->b_enc = b_encode;
InitOmxEventQueue(&p_sys->event_queue);
@@ -1615,6 +1675,9 @@ static OMX_ERRORTYPE OmxEventHandler( OMX_HANDLETYPE omx_handle,
msg_Dbg( p_dec, "Unhandled setting change %x", (unsigned int)data_2 );
}
break;
+ case OMX_EventParamOrConfigChanged:
+ UpdatePixelAspect(p_dec);
+ break;
default:
break;
--
1.8.5.2
|