[vlc-commits] omxil: Passthrough aspect ratio from input format.

Julian Scheel git at videolan.org
Fri Feb 7 19:44:35 CET 2014


vlc | branch: master | Julian Scheel <julian at jusst.de> | Fri Sep 27 14:32:40 2013 +0200| [41067d217d365d40a27920c117453c7b0d4a8fd6] | committer: Martin Storsjö

omxil: Passthrough aspect ratio from input format.

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.

Signed-off-by: Martin Storsjö <martin at martin.st>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=41067d217d365d40a27920c117453c7b0d4a8fd6
---

 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 */



More information about the vlc-commits mailing list