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

Francois Cartegnie git at videolan.org
Wed Dec 20 19:34:48 CET 2017


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

ImageWrite: create filters when RGB masks differ

refs #13349

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

 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