]> git.sesse.net Git - vlc/commitdiff
Do not load a filter for J4xy -> I4xy in vout_display.
authorLaurent Aimar <fenrir@videolan.org>
Sun, 30 Aug 2009 18:09:12 +0000 (20:09 +0200)
committerLaurent Aimar <fenrir@videolan.org>
Sun, 30 Aug 2009 18:11:06 +0000 (20:11 +0200)
 It's not perfect, as they do not have the same dynamic, but it costs a lot
of CPU for something not that visible.
 If an option is wanted, it is easy to add.

src/video_output/display.c

index 4774ba91906de850c03ec5f124c6624d2c3ba58e..33c825c7b36e65a6efda79dda4c165e0b3cb090b 100644 (file)
@@ -364,10 +364,19 @@ static void VoutDisplayCreateRender(vout_display_t *vd)
     v_dst.i_sar_num = 0;
     v_dst.i_sar_den = 0;
 
-    const bool convert = memcmp(&v_src, &v_dst, sizeof(v_src)) != 0;
+    video_format_t v_dst_cmp = v_dst;
+    if ((v_src.i_chroma == VLC_CODEC_J420 && v_dst.i_chroma == VLC_CODEC_I420) ||
+        (v_src.i_chroma == VLC_CODEC_J422 && v_dst.i_chroma == VLC_CODEC_I422) ||
+        (v_src.i_chroma == VLC_CODEC_J440 && v_dst.i_chroma == VLC_CODEC_I440) ||
+        (v_src.i_chroma == VLC_CODEC_J444 && v_dst.i_chroma == VLC_CODEC_I444))
+        v_dst_cmp.i_chroma = v_src.i_chroma;
+
+    const bool convert = memcmp(&v_src, &v_dst_cmp, sizeof(v_src)) != 0;
     if (!convert)
         return;
 
+    msg_Err(vd, "A filter to adapt decoder to display is needed");
+
     osys->filters = filter_chain_New(vd, "video filter2", false,
                                      FilterAllocationInit,
                                      FilterAllocationClean, NULL);
@@ -379,13 +388,18 @@ static void VoutDisplayCreateRender(vout_display_t *vd)
 
     /* */
     es_format_t dst;
-    es_format_InitFromVideo(&dst, &v_dst);
 
-    filter_chain_Reset(osys->filters, &src, &dst);
+    filter_t *filter;
+    for (int i = 0; i < 1 + (v_dst_cmp.i_chroma != v_dst.i_chroma); i++) {
 
-    msg_Err(vd, "A filter to adapt decoder to display is needed");
-    filter_t *filter = filter_chain_AppendFilter(osys->filters,
-                                                 NULL, NULL, &src, &dst);
+        es_format_InitFromVideo(&dst, i == 0 ? &v_dst : &v_dst_cmp);
+
+        filter_chain_Reset(osys->filters, &src, &dst);
+        filter = filter_chain_AppendFilter(osys->filters,
+                                           NULL, NULL, &src, &dst);
+        if (filter)
+            break;
+    }
     if (!filter)
     {
         msg_Err(vd, "VoutDisplayCreateRender FAILED");