]> git.sesse.net Git - vlc/commitdiff
omxil: Passthrough aspect ratio from input format.
authorJulian Scheel <julian@jusst.de>
Fri, 27 Sep 2013 12:32:40 +0000 (14:32 +0200)
committerMartin Storsjö <martin@martin.st>
Fri, 7 Feb 2014 18:42:57 +0000 (20:42 +0200)
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@martin.st>
modules/codec/omxil/omxil.c
modules/codec/omxil/omxil.h

index 3e4c1047e8b3af2121233e6d1e8417be18d825df..2800e448da85d8a52d3760ca4f68de0b67000324 100644 (file)
@@ -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)
     {
index c040d3bc0ea3f80e8d65941fdbd7b8d8122b068e..1d6ea7664d701ce5ed97267edd2d06b0d1927fad 100644 (file)
@@ -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 */