[vlc-devel] [PATCH 2/4] omxil: Passthrough aspect ratio from input format.

Martin Storsjö martin at martin.st
Thu Feb 6 14:05:09 CET 2014


From: Julian Scheel <julian at jusst.de>

If the input format has a valid pixel aspect ratio set (ie from the
packetizer) pass this into the output format. This helps for omx
implementations which do not report the aspect ratio.
For omx implementations which provide aspect ratio information give these
precedence over the incoming values.
---
Updated the patch to use a flag in the struct instead of
explicitly looking for the OMX.broadcom decoder - we don't know
for sure if all OMX.broadcom instances actually support this
API, only that the one on the RPi does.
---
 modules/codec/omxil/omxil.c | 18 ++++++++++++++++--
 modules/codec/omxil/omxil.h |  2 ++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/modules/codec/omxil/omxil.c b/modules/codec/omxil/omxil.c
index 3e4c104..2800e44 100644
--- a/modules/codec/omxil/omxil.c
+++ b/modules/codec/omxil/omxil.c
@@ -732,9 +732,10 @@ static OMX_ERRORTYPE InitialiseComponent(decoder_t *p_dec,
 
         omx_error = OMX_SetParameter(omx_handle,
                 OMX_IndexConfigRequestCallback, &notifications);
-        if (omx_error == OMX_ErrorNone)
+        if (omx_error == OMX_ErrorNone) {
             msg_Dbg(p_dec, "Enabled aspect ratio notifications");
-        else
+            p_sys->b_aspect_ratio_handled = true;
+        } else
             msg_Dbg(p_dec, "Could not enable aspect ratio notifications");
     }
 
@@ -1245,6 +1246,19 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
         return NULL;
     }
 
+    /* Use the aspect ratio provided by the input (ie read from packetizer).
+     * In case the we get aspect ratio info from the decoder (as in the
+     * broadcom OMX implementation on RPi), don't let the packetizer values
+     * override what the decoder says, if anything - otherwise always update
+     * even if it already is set (since it can change within a stream). */
+    if((p_dec->fmt_in.video.i_sar_num != 0 && p_dec->fmt_in.video.i_sar_den != 0) &&
+       (p_dec->fmt_out.video.i_sar_num == 0 || p_dec->fmt_out.video.i_sar_den == 0 ||
+             !p_sys->b_aspect_ratio_handled))
+    {
+        p_dec->fmt_out.video.i_sar_num = p_dec->fmt_in.video.i_sar_num;
+        p_dec->fmt_out.video.i_sar_den = p_dec->fmt_in.video.i_sar_den;
+    }
+
     /* Take care of decoded frames first */
     while(!p_pic)
     {
diff --git a/modules/codec/omxil/omxil.h b/modules/codec/omxil/omxil.h
index c040d3b..1d6ea76 100644
--- a/modules/codec/omxil/omxil.h
+++ b/modules/codec/omxil/omxil.h
@@ -94,6 +94,8 @@ struct decoder_sys_t
 
     bool b_error;
 
+    bool b_aspect_ratio_handled;
+
     date_t end_date;
 
     size_t i_nal_size_length; /* Length of the NAL size field for H264 */
-- 
1.8.3.4 (Apple Git-47)




More information about the vlc-devel mailing list