[vlc-commits] nvdec: set the SAR before getting the decoder device

Steve Lhomme git at videolan.org
Fri Dec 13 17:28:12 CET 2019


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Fri Dec 13 13:59:02 2019 +0100| [97e3c89d7d31ae992eef5867c5bd56173dcce504] | committer: Steve Lhomme

nvdec: set the SAR before getting the decoder device

To create the vout for the decoder device we can call decoder_UpdateVideoOutput
but only when we know the output format. Otherwise we need to set a usable
output format before we call decoder_GetDecoderDevice().

Prioritize the SAR from the container over the decoder one.

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

 modules/hw/nvdec/nvdec.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/modules/hw/nvdec/nvdec.c b/modules/hw/nvdec/nvdec.c
index a97e6a506a..5c8275387d 100644
--- a/modules/hw/nvdec/nvdec.c
+++ b/modules/hw/nvdec/nvdec.c
@@ -749,6 +749,8 @@ static int OpenDecoder(vlc_object_t *p_this)
     uint8_t i_depth_luma;
     cudaVideoChromaFormat cudaChroma;
 
+    int i_sar_num, i_sar_den = 0;
+
     // try different output
 #define ALIGN(v, mod) ((v + (mod - 1)) & ~(mod - 1))
     if (p_sys->b_is_hxxx)
@@ -796,12 +798,10 @@ static int OpenDecoder(vlc_object_t *p_this)
             p_dec->fmt_out.video.i_visible_height = i_vh;
         }
 
-        int i_sar_num, i_sar_den;
-        if (VLC_SUCCESS ==
+        if (VLC_SUCCESS !=
             hxxx_helper_get_current_sar(&p_sys->hh, &i_sar_num, &i_sar_den))
         {
-            p_dec->fmt_out.video.i_sar_num = i_sar_num;
-            p_dec->fmt_out.video.i_sar_den = i_sar_den;
+            i_sar_den = 0;
         }
     }
     else
@@ -830,6 +830,19 @@ static int OpenDecoder(vlc_object_t *p_this)
             }
         }
     }
+    if (p_dec->fmt_in.video.i_sar_den != 0)
+    {
+        i_sar_num = p_dec->fmt_in.video.i_sar_num;
+        i_sar_den = p_dec->fmt_in.video.i_sar_den;
+    }
+    if (i_sar_den == 0)
+    {
+        i_sar_num = 1;
+        i_sar_den = 1;
+    }
+
+    p_dec->fmt_out.video.i_sar_num = i_sar_num;
+    p_dec->fmt_out.video.i_sar_den = i_sar_den;
 #undef ALIGN
     p_dec->fmt_out.video.i_bits_per_pixel = i_depth_luma;
     p_dec->fmt_out.video.i_frame_rate = p_dec->fmt_in.video.i_frame_rate;



More information about the vlc-commits mailing list