@@ -136,14 +136,10 @@ bool COMXVideo::PortSettingsChanged()
136
136
{
137
137
OMX_ERRORTYPE omx_err = OMX_ErrorNone;
138
138
std::string componentName = " " ;
139
- float par = m_pixel_aspect;
140
139
141
140
if (m_settings_changed)
142
141
{
143
- SetVideoRect (m_src_rect, m_dst_rect);
144
142
m_omx_decoder.DisablePort (m_omx_decoder.GetOutputPort (), true );
145
- m_omx_decoder.EnablePort (m_omx_decoder.GetOutputPort (), true );
146
- return true ;
147
143
}
148
144
149
145
OMX_PARAM_PORTDEFINITIONTYPE port_image;
@@ -152,7 +148,26 @@ bool COMXVideo::PortSettingsChanged()
152
148
omx_err = m_omx_decoder.GetParameter (OMX_IndexParamPortDefinition, &port_image);
153
149
if (omx_err != OMX_ErrorNone)
154
150
{
155
- CLog::Log (LOGERROR, " %s::%s - error m_omx_decoder.GetParameter(OMX_IndexParamPortDefinition) omx_err(0x%08x)\n " , CLASSNAME, __func__, omx_err);
151
+ CLog::Log (LOGERROR, " %s::%s - error m_omx_decoder.GetParameter(OMX_IndexParamPortDefinition) omx_err(0x%08x)" , CLASSNAME, __func__, omx_err);
152
+ }
153
+
154
+ OMX_CONFIG_POINTTYPE pixel_aspect;
155
+ OMX_INIT_STRUCTURE (pixel_aspect);
156
+ pixel_aspect.nPortIndex = m_omx_decoder.GetOutputPort ();
157
+ omx_err = m_omx_decoder.GetParameter (OMX_IndexParamBrcmPixelAspectRatio, &pixel_aspect);
158
+ if (omx_err != OMX_ErrorNone)
159
+ {
160
+ CLog::Log (LOGERROR, " %s::%s - error m_omx_decoder.GetParameter(OMX_IndexParamBrcmPixelAspectRatio) omx_err(0x%08x)" , CLASSNAME, __func__, omx_err);
161
+ }
162
+
163
+ if (pixel_aspect.nX && pixel_aspect.nY )
164
+ m_pixel_aspect = (float )pixel_aspect.nX / (float )pixel_aspect.nY ;
165
+
166
+ if (m_settings_changed)
167
+ {
168
+ SetVideoRect (m_src_rect, m_dst_rect);
169
+ m_omx_decoder.EnablePort (m_omx_decoder.GetOutputPort (), true );
170
+ return true ;
156
171
}
157
172
158
173
OMX_CONFIG_INTERLACETYPE interlace;
@@ -227,27 +242,6 @@ bool COMXVideo::PortSettingsChanged()
227
242
}
228
243
}
229
244
230
- // only set aspect when we have a aspect and display doesn't match the aspect
231
- if (par != 0 .0f && fabs (par - 1 .0f ) > 0 .01f )
232
- {
233
- OMX_CONFIG_DISPLAYREGIONTYPE configDisplay;
234
- OMX_INIT_STRUCTURE (configDisplay);
235
- configDisplay.nPortIndex = m_omx_render.GetInputPort ();
236
-
237
- AVRational aspect;
238
- aspect = av_d2q (par, 100 );
239
- configDisplay.set = OMX_DISPLAY_SET_PIXEL;
240
- configDisplay.pixel_x = aspect.num ;
241
- configDisplay.pixel_y = aspect.den ;
242
- printf (" Aspect : num %d den %d pixel aspect %f\n " , aspect.num , aspect.den , par);
243
- omx_err = m_omx_render.SetConfig (OMX_IndexConfigDisplayRegion, &configDisplay);
244
- if (omx_err != OMX_ErrorNone)
245
- {
246
- CLog::Log (LOGERROR, " COMXVideo::Open error OMX_IndexConfigDisplayRegion omx_err(0x%08x)\n " , omx_err);
247
- return false ;
248
- }
249
- }
250
-
251
245
if (m_deinterlace)
252
246
{
253
247
m_omx_tunnel_decoder.Initialize (&m_omx_decoder, m_omx_decoder.GetOutputPort (), &m_omx_image_fx, m_omx_image_fx.GetInputPort ());
@@ -523,6 +517,20 @@ bool COMXVideo::Open(COMXStreamInfo &hints, OMXClock *clock, const CRect &DestRe
523
517
return false ;
524
518
}
525
519
520
+ // request portsettingschanged on aspect ratio change
521
+ OMX_CONFIG_REQUESTCALLBACKTYPE notifications;
522
+ OMX_INIT_STRUCTURE (notifications);
523
+ notifications.nPortIndex = m_omx_decoder.GetOutputPort ();
524
+ notifications.nIndex = OMX_IndexParamBrcmPixelAspectRatio;
525
+ notifications.bEnable = OMX_TRUE;
526
+
527
+ omx_err = m_omx_decoder.SetParameter ((OMX_INDEXTYPE)OMX_IndexConfigRequestCallback, ¬ifications);
528
+ if (omx_err != OMX_ErrorNone)
529
+ {
530
+ CLog::Log (LOGERROR, " COMXVideo::Open OMX_IndexConfigRequestCallback error (0%08x)\n " , omx_err);
531
+ return false ;
532
+ }
533
+
526
534
OMX_PARAM_BRCMVIDEODECODEERRORCONCEALMENTTYPE concanParam;
527
535
OMX_INIT_STRUCTURE (concanParam);
528
536
concanParam.bStartWithValidFrame = OMX_FALSE;
@@ -959,6 +967,14 @@ int COMXVideo::Decode(uint8_t *pData, int iSize, double dts, double pts)
959
967
CLog::Log (LOGERROR, " %s::%s - error PortSettingsChanged omx_err(0x%08x)\n " , CLASSNAME, __func__, omx_err);
960
968
}
961
969
}
970
+ omx_err = m_omx_decoder.WaitForEvent (OMX_EventParamOrConfigChanged, 0 );
971
+ if (omx_err == OMX_ErrorNone)
972
+ {
973
+ if (!PortSettingsChanged ())
974
+ {
975
+ CLog::Log (LOGERROR, " %s::%s - error PortSettingsChanged (EventParamOrConfigChanged) omx_err(0x%08x)\n " , CLASSNAME, __func__, omx_err);
976
+ }
977
+ }
962
978
}
963
979
return true ;
964
980
}
@@ -980,32 +996,47 @@ void COMXVideo::Reset(void)
980
996
// /////////////////////////////////////////////////////////////////////////////////////////
981
997
void COMXVideo::SetVideoRect (const CRect& SrcRect, const CRect& DestRect)
982
998
{
983
- if (!m_settings_changed || DestRect.x2 <= DestRect.x1 || DestRect.y2 <= DestRect.y1 )
999
+ if ( !m_settings_changed || !(( DestRect.x2 > DestRect.x1 && DestRect.y2 > DestRect.y1 ) || m_pixel_aspect != 0 . 0f ) )
984
1000
return ;
985
1001
1002
+ OMX_ERRORTYPE omx_err;
986
1003
OMX_CONFIG_DISPLAYREGIONTYPE configDisplay;
987
-
988
1004
OMX_INIT_STRUCTURE (configDisplay);
989
1005
configDisplay.nPortIndex = m_omx_render.GetInputPort ();
990
- configDisplay.fullscreen = OMX_FALSE;
991
- configDisplay.noaspect = OMX_TRUE;
992
-
993
- configDisplay.set = (OMX_DISPLAYSETTYPE)(OMX_DISPLAY_SET_DEST_RECT|OMX_DISPLAY_SET_SRC_RECT|OMX_DISPLAY_SET_FULLSCREEN|OMX_DISPLAY_SET_NOASPECT);
994
- configDisplay.dest_rect .x_offset = (int )(DestRect.x1 +0 .5f );
995
- configDisplay.dest_rect .y_offset = (int )(DestRect.y1 +0 .5f );
996
- configDisplay.dest_rect .width = (int )(DestRect.Width ()+0 .5f );
997
- configDisplay.dest_rect .height = (int )(DestRect.Height ()+0 .5f );
998
1006
999
- configDisplay.src_rect .x_offset = (int )(SrcRect.x1 +0 .5f );
1000
- configDisplay.src_rect .y_offset = (int )(SrcRect.y1 +0 .5f );
1001
- configDisplay.src_rect .width = (int )(SrcRect.Width ()+0 .5f );
1002
- configDisplay.src_rect .height = (int )(SrcRect.Height ()+0 .5f );
1003
-
1004
- m_omx_render.SetConfig (OMX_IndexConfigDisplayRegion, &configDisplay);
1007
+ // configured dest_rect takes precedence
1008
+ if (DestRect.x2 > DestRect.x1 && DestRect.y2 > DestRect.y1 )
1009
+ {
1010
+ configDisplay.fullscreen = OMX_FALSE;
1011
+ configDisplay.noaspect = OMX_TRUE;
1012
+
1013
+ configDisplay.set = (OMX_DISPLAYSETTYPE)(OMX_DISPLAY_SET_DEST_RECT|OMX_DISPLAY_SET_SRC_RECT|OMX_DISPLAY_SET_FULLSCREEN|OMX_DISPLAY_SET_NOASPECT);
1014
+ configDisplay.dest_rect .x_offset = (int )(DestRect.x1 +0 .5f );
1015
+ configDisplay.dest_rect .y_offset = (int )(DestRect.y1 +0 .5f );
1016
+ configDisplay.dest_rect .width = (int )(DestRect.Width ()+0 .5f );
1017
+ configDisplay.dest_rect .height = (int )(DestRect.Height ()+0 .5f );
1018
+
1019
+ configDisplay.src_rect .x_offset = (int )(SrcRect.x1 +0 .5f );
1020
+ configDisplay.src_rect .y_offset = (int )(SrcRect.y1 +0 .5f );
1021
+ configDisplay.src_rect .width = (int )(SrcRect.Width ()+0 .5f );
1022
+ configDisplay.src_rect .height = (int )(SrcRect.Height ()+0 .5f );
1023
+ }
1024
+ else /* if (m_pixel_aspect != 0.0f) */
1025
+ {
1026
+ AVRational aspect = av_d2q (m_pixel_aspect, 100 );
1027
+ configDisplay.set = OMX_DISPLAY_SET_PIXEL;
1028
+ configDisplay.pixel_x = aspect.num ;
1029
+ configDisplay.pixel_y = aspect.den ;
1030
+ }
1031
+ omx_err = m_omx_render.SetConfig (OMX_IndexConfigDisplayRegion, &configDisplay);
1032
+ if (omx_err != OMX_ErrorNone)
1033
+ {
1034
+ CLog::Log (LOGERROR, " COMXVideo::Open error OMX_IndexConfigDisplayRegion omx_err(0x%08x)\n " , omx_err);
1035
+ }
1005
1036
1006
- printf (" dest_rect.x_offset %d dest_rect.y_offset %d dest_rect.width %d dest_rect.height %d\n " ,
1037
+ printf (" dest_rect.x_offset %d dest_rect.y_offset %d dest_rect.width %d dest_rect.height %d, pixel_aspect %.2f \n " ,
1007
1038
configDisplay.dest_rect .x_offset , configDisplay.dest_rect .y_offset ,
1008
- configDisplay.dest_rect .width , configDisplay.dest_rect .height );
1039
+ configDisplay.dest_rect .width , configDisplay.dest_rect .height , m_pixel_aspect );
1009
1040
}
1010
1041
1011
1042
int COMXVideo::GetInputBufferSize ()
0 commit comments