[vlc-commits] ImageWrite: create filters when RGB masks differ

Francois Cartegnie git at videolan.org
Thu Dec 21 11:10:44 CET 2017


vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Dec 20 19:33:03 2017 +0100| [31960f45f3b0e2ba09d82a48ac225555ddd52f87] | committer: Francois Cartegnie

ImageWrite: create filters when RGB masks differ

refs #13349

(cherry picked from commit b7b69fcf8caad193a37661b0a1f9c658e2fce6b0)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=31960f45f3b0e2ba09d82a48ac225555ddd52f87
---

 src/misc/image.c | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/src/misc/image.c b/src/misc/image.c
index 7c3ad995c8..6ea0e11bbd 100644
--- a/src/misc/image.c
+++ b/src/misc/image.c
@@ -317,6 +317,29 @@ error:
     return NULL;
 }
 
+/* FIXME: refactor by splitting video_format_IsSimilar() API */
+static bool BitMapFormatIsSimilar( const video_format_t *f1,
+                                   const video_format_t *f2 )
+{
+    if( f1->i_chroma == VLC_CODEC_RGB15 ||
+        f1->i_chroma == VLC_CODEC_RGB16 ||
+        f1->i_chroma == VLC_CODEC_RGB24 ||
+        f1->i_chroma == VLC_CODEC_RGB32 )
+    {
+        video_format_t v1 = *f1;
+        video_format_t v2 = *f2;
+
+        video_format_FixRgb( &v1 );
+        video_format_FixRgb( &v2 );
+
+        if( v1.i_rmask != v2.i_rmask ||
+            v1.i_gmask != v2.i_gmask ||
+            v1.i_bmask != v2.i_bmask )
+            return false;
+    }
+    return true;
+}
+
 /**
  * Write an image
  *
@@ -349,14 +372,16 @@ static block_t *ImageWrite( image_handler_t *p_image, picture_t *p_pic,
     /* Check if we need chroma conversion or resizing */
     if( p_image->p_enc->fmt_in.video.i_chroma != p_fmt_in->i_chroma ||
         p_image->p_enc->fmt_in.video.i_width != p_fmt_in->i_width ||
-        p_image->p_enc->fmt_in.video.i_height != p_fmt_in->i_height )
+        p_image->p_enc->fmt_in.video.i_height != p_fmt_in->i_height ||
+       !BitMapFormatIsSimilar( &p_image->p_enc->fmt_in.video, p_fmt_in ) )
     {
         picture_t *p_tmp_pic;
 
         if( p_image->p_filter )
         if( p_image->p_filter->fmt_in.video.i_chroma != p_fmt_in->i_chroma ||
             p_image->p_filter->fmt_out.video.i_chroma !=
-            p_image->p_enc->fmt_in.video.i_chroma )
+            p_image->p_enc->fmt_in.video.i_chroma ||
+           !BitMapFormatIsSimilar( &p_image->p_filter->fmt_in.video, p_fmt_in ) )
         {
             /* We need to restart a new filter */
             DeleteFilter( p_image->p_filter );



More information about the vlc-commits mailing list