Move YUVP filter to Video Chroma
authorJean-Baptiste Kempf <jb@videolan.org>
Sat, 16 Apr 2016 09:04:44 +0000 (11:04 +0200)
committerJean-Baptiste Kempf <jb@videolan.org>
Sat, 16 Apr 2016 09:11:45 +0000 (11:11 +0200)
modules/video_chroma/Makefile.am
modules/video_chroma/yuvp.c [new file with mode: 0644]
modules/video_filter/Makefile.am
modules/video_filter/yuvp.c [deleted file]
po/POTFILES.in

index 1b0f7b6..7bcbf5a 100644 (file)
@@ -33,6 +33,8 @@ libyuy2_i420_plugin_la_SOURCES = video_chroma/yuy2_i420.c
 
 libyuy2_i422_plugin_la_SOURCES = video_chroma/yuy2_i422.c
 
+libyuvp_plugin_la_SOURCES = video_chroma/yuvp.c
+
 chroma_LTLIBRARIES = \
        libi420_rgb_plugin.la \
        libi420_yuy2_plugin.la \
@@ -43,6 +45,7 @@ chroma_LTLIBRARIES = \
        libyuy2_i422_plugin.la \
        librv32_plugin.la \
        libchain_plugin.la \
+       libyuvp_plugin.la \
        $(LTLIBswscale)
 
 EXTRA_LTLIBRARIES += libswscale_plugin.la libchroma_omx_plugin.la
diff --git a/modules/video_chroma/yuvp.c b/modules/video_chroma/yuvp.c
new file mode 100644 (file)
index 0000000..c8ffbf2
--- /dev/null
@@ -0,0 +1,244 @@
+/*****************************************************************************
+ * yuvp.c: YUVP to YUVA/RGBA chroma converter
+ *****************************************************************************
+ * Copyright (C) 2008 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Laurent Aimar < fenrir @ videolan.org >
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_plugin.h>
+#include <vlc_filter.h>
+#include <assert.h>
+
+/* TODO:
+ *  Add anti-aliasing support (specially for DVD where only 4 colors are used)
+ */
+
+/*****************************************************************************
+ * Module descriptor
+ *****************************************************************************/
+static int  Open ( vlc_object_t * );
+static void Close( vlc_object_t * );
+
+vlc_module_begin ()
+    set_description( N_("YUVP converter") )
+    set_capability( "video filter2", 10 )
+    set_callbacks( Open, Close )
+vlc_module_end ()
+
+/****************************************************************************
+ * Local prototypes
+ ****************************************************************************/
+static picture_t *Filter( filter_t *, picture_t * );
+static void Yuv2Rgb( uint8_t *r, uint8_t *g, uint8_t *b, int y1, int u1, int v1 );
+
+/*****************************************************************************
+ * Open: probe the filter and return score
+ *****************************************************************************/
+static int Open( vlc_object_t *p_this )
+{
+    filter_t *p_filter = (filter_t*)p_this;
+
+    /* It only supports YUVP to YUVA/RGBA without scaling
+     * (if scaling is required another filter can do it) */
+    if( p_filter->fmt_in.video.i_chroma != VLC_CODEC_YUVP ||
+        ( p_filter->fmt_out.video.i_chroma != VLC_CODEC_YUVA &&
+          p_filter->fmt_out.video.i_chroma != VLC_CODEC_RGBA &&
+          p_filter->fmt_out.video.i_chroma != VLC_CODEC_ARGB ) ||
+        p_filter->fmt_in.video.i_width  != p_filter->fmt_out.video.i_width ||
+        p_filter->fmt_in.video.i_height != p_filter->fmt_out.video.i_height ||
+        p_filter->fmt_in.video.orientation != p_filter->fmt_out.video.orientation )
+    {
+        return VLC_EGENERIC;
+    }
+
+    p_filter->pf_video_filter = Filter;
+
+    msg_Dbg( p_filter, "YUVP to %4.4s converter",
+             (const char*)&p_filter->fmt_out.video.i_chroma );
+
+    return VLC_SUCCESS;
+}
+
+/*****************************************************************************
+ * Close: clean up the filter
+ *****************************************************************************/
+static void Close( vlc_object_t *p_this )
+{
+    VLC_UNUSED(p_this );
+}
+
+/****************************************************************************
+ * Filter: the whole thing
+ ****************************************************************************/
+static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
+{
+    picture_t *p_out;
+
+    if( !p_pic )
+        return NULL;
+
+    const video_palette_t *p_yuvp = p_filter->fmt_in.video.p_palette;
+
+    assert( p_yuvp != NULL );
+    assert( p_filter->fmt_in.video.i_chroma == VLC_CODEC_YUVP );
+    assert( p_filter->fmt_in.video.i_width == p_filter->fmt_out.video.i_width );
+    assert( p_filter->fmt_in.video.i_height == p_filter->fmt_out.video.i_height );
+
+    /* Request output picture */
+    p_out = filter_NewPicture( p_filter );
+    if( !p_out )
+    {
+        picture_Release( p_pic );
+        return NULL;
+    }
+
+    if( p_filter->fmt_out.video.i_chroma == VLC_CODEC_YUVA )
+    {
+        for( unsigned int y = 0; y < p_filter->fmt_in.video.i_height; y++ )
+        {
+            const uint8_t *p_line = &p_pic->p->p_pixels[y*p_pic->p->i_pitch];
+            uint8_t *p_y = &p_out->Y_PIXELS[y*p_out->Y_PITCH];
+            uint8_t *p_u = &p_out->U_PIXELS[y*p_out->U_PITCH];
+            uint8_t *p_v = &p_out->V_PIXELS[y*p_out->V_PITCH];
+            uint8_t *p_a = &p_out->A_PIXELS[y*p_out->A_PITCH];
+
+            for( unsigned int x = 0; x < p_filter->fmt_in.video.i_width; x++ )
+            {
+                const int v = p_line[x];
+
+                if( v > p_yuvp->i_entries )  /* maybe assert ? */
+                    continue;
+
+                p_y[x] = p_yuvp->palette[v][0];
+                p_u[x] = p_yuvp->palette[v][1];
+                p_v[x] = p_yuvp->palette[v][2];
+                p_a[x] = p_yuvp->palette[v][3];
+            }
+        }
+    }
+    else if( p_filter->fmt_out.video.i_chroma == VLC_CODEC_RGBA )
+    {
+        video_palette_t rgbp;
+
+        /* Create a RGBA palette */
+        rgbp.i_entries = p_yuvp->i_entries;
+        for( int i = 0; i < p_yuvp->i_entries; i++ )
+        {
+            Yuv2Rgb( &rgbp.palette[i][0], &rgbp.palette[i][1], &rgbp.palette[i][2],
+                     p_yuvp->palette[i][0], p_yuvp->palette[i][1], p_yuvp->palette[i][2] );
+            rgbp.palette[i][3] = p_yuvp->palette[i][3];
+        }
+
+        for( unsigned int y = 0; y < p_filter->fmt_in.video.i_height; y++ )
+        {
+            const uint8_t *p_line = &p_pic->p->p_pixels[y*p_pic->p->i_pitch];
+            uint8_t *p_rgba = &p_out->p->p_pixels[y*p_out->p->i_pitch];
+
+            for( unsigned int x = 0; x < p_filter->fmt_in.video.i_width; x++ )
+            {
+                const int v = p_line[x];
+
+                if( v >= rgbp.i_entries )  /* maybe assert ? */
+                    continue;
+
+                p_rgba[4*x+0] = rgbp.palette[v][0];
+                p_rgba[4*x+1] = rgbp.palette[v][1];
+                p_rgba[4*x+2] = rgbp.palette[v][2];
+                p_rgba[4*x+3] = rgbp.palette[v][3];
+            }
+        }
+    }
+    else
+    {
+        video_palette_t rgbp;
+
+        assert( p_filter->fmt_out.video.i_chroma == VLC_CODEC_ARGB );
+        /* Create a RGBA palette */
+        rgbp.i_entries = p_yuvp->i_entries;
+        for( int i = 0; i < p_yuvp->i_entries; i++ )
+        {
+            Yuv2Rgb( &rgbp.palette[i][1], &rgbp.palette[i][2], &rgbp.palette[i][3],
+                     p_yuvp->palette[i][0], p_yuvp->palette[i][1], p_yuvp->palette[i][2] );
+            rgbp.palette[i][0] = p_yuvp->palette[i][3];
+        }
+
+        for( unsigned int y = 0; y < p_filter->fmt_in.video.i_height; y++ )
+        {
+            const uint8_t *p_line = &p_pic->p->p_pixels[y*p_pic->p->i_pitch];
+            uint8_t *p_rgba = &p_out->p->p_pixels[y*p_out->p->i_pitch];
+
+            for( unsigned int x = 0; x < p_filter->fmt_in.video.i_width; x++ )
+            {
+                const int v = p_line[x];
+
+                if( v >= rgbp.i_entries )  /* maybe assert ? */
+                    continue;
+
+                p_rgba[4*x+0] = rgbp.palette[v][0];
+                p_rgba[4*x+1] = rgbp.palette[v][1];
+                p_rgba[4*x+2] = rgbp.palette[v][2];
+                p_rgba[4*x+3] = rgbp.palette[v][3];
+            }
+        }
+
+    }
+
+    picture_CopyProperties( p_out, p_pic );
+    picture_Release( p_pic );
+    return p_out;
+}
+
+/* FIXME copied from blend.c */
+static inline uint8_t vlc_uint8( int v )
+{
+    if( v > 255 )
+        return 255;
+    else if( v < 0 )
+        return 0;
+    return v;
+}
+static void Yuv2Rgb( uint8_t *r, uint8_t *g, uint8_t *b, int y1, int u1, int v1 )
+{
+    /* macros used for YUV pixel conversions */
+#   define SCALEBITS 10
+#   define ONE_HALF  (1 << (SCALEBITS - 1))
+#   define FIX(x)    ((int) ((x) * (1<<SCALEBITS) + 0.5))
+
+    int y, cb, cr, r_add, g_add, b_add;
+
+    cb = u1 - 128;
+    cr = v1 - 128;
+    r_add = FIX(1.40200*255.0/224.0) * cr + ONE_HALF;
+    g_add = - FIX(0.34414*255.0/224.0) * cb
+            - FIX(0.71414*255.0/224.0) * cr + ONE_HALF;
+    b_add = FIX(1.77200*255.0/224.0) * cb + ONE_HALF;
+    y = (y1 - 16) * FIX(255.0/219.0);
+    *r = vlc_uint8( (y + r_add) >> SCALEBITS );
+    *g = vlc_uint8( (y + g_add) >> SCALEBITS );
+    *b = vlc_uint8( (y + b_add) >> SCALEBITS );
+#undef FIX
+}
index b2ff9cd..d853717 100644 (file)
@@ -66,7 +66,6 @@ libtransform_plugin_la_SOURCES = video_filter/transform.c
 libvhs_plugin_la_SOURCES = video_filter/vhs.c
 libwave_plugin_la_SOURCES = video_filter/wave.c
 libwave_plugin_la_LIBADD = $(LIBM)
-libyuvp_plugin_la_SOURCES = video_filter/yuvp.c
 
 video_filter_LTLIBRARIES = \
        libadjust_plugin.la \
@@ -98,7 +97,6 @@ video_filter_LTLIBRARIES = \
        libtransform_plugin.la \
        libwave_plugin.la \
        libgradfun_plugin.la \
-       libyuvp_plugin.la \
        libantiflicker_plugin.la \
        libhqdn3d_plugin.la \
        libanaglyph_plugin.la \
diff --git a/modules/video_filter/yuvp.c b/modules/video_filter/yuvp.c
deleted file mode 100644 (file)
index c8ffbf2..0000000
+++ /dev/null
@@ -1,244 +0,0 @@
-/*****************************************************************************
- * yuvp.c: YUVP to YUVA/RGBA chroma converter
- *****************************************************************************
- * Copyright (C) 2008 VLC authors and VideoLAN
- * $Id$
- *
- * Authors: Laurent Aimar < fenrir @ videolan.org >
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-/*****************************************************************************
- * Preamble
- *****************************************************************************/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <vlc_common.h>
-#include <vlc_plugin.h>
-#include <vlc_filter.h>
-#include <assert.h>
-
-/* TODO:
- *  Add anti-aliasing support (specially for DVD where only 4 colors are used)
- */
-
-/*****************************************************************************
- * Module descriptor
- *****************************************************************************/
-static int  Open ( vlc_object_t * );
-static void Close( vlc_object_t * );
-
-vlc_module_begin ()
-    set_description( N_("YUVP converter") )
-    set_capability( "video filter2", 10 )
-    set_callbacks( Open, Close )
-vlc_module_end ()
-
-/****************************************************************************
- * Local prototypes
- ****************************************************************************/
-static picture_t *Filter( filter_t *, picture_t * );
-static void Yuv2Rgb( uint8_t *r, uint8_t *g, uint8_t *b, int y1, int u1, int v1 );
-
-/*****************************************************************************
- * Open: probe the filter and return score
- *****************************************************************************/
-static int Open( vlc_object_t *p_this )
-{
-    filter_t *p_filter = (filter_t*)p_this;
-
-    /* It only supports YUVP to YUVA/RGBA without scaling
-     * (if scaling is required another filter can do it) */
-    if( p_filter->fmt_in.video.i_chroma != VLC_CODEC_YUVP ||
-        ( p_filter->fmt_out.video.i_chroma != VLC_CODEC_YUVA &&
-          p_filter->fmt_out.video.i_chroma != VLC_CODEC_RGBA &&
-          p_filter->fmt_out.video.i_chroma != VLC_CODEC_ARGB ) ||
-        p_filter->fmt_in.video.i_width  != p_filter->fmt_out.video.i_width ||
-        p_filter->fmt_in.video.i_height != p_filter->fmt_out.video.i_height ||
-        p_filter->fmt_in.video.orientation != p_filter->fmt_out.video.orientation )
-    {
-        return VLC_EGENERIC;
-    }
-
-    p_filter->pf_video_filter = Filter;
-
-    msg_Dbg( p_filter, "YUVP to %4.4s converter",
-             (const char*)&p_filter->fmt_out.video.i_chroma );
-
-    return VLC_SUCCESS;
-}
-
-/*****************************************************************************
- * Close: clean up the filter
- *****************************************************************************/
-static void Close( vlc_object_t *p_this )
-{
-    VLC_UNUSED(p_this );
-}
-
-/****************************************************************************
- * Filter: the whole thing
- ****************************************************************************/
-static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
-{
-    picture_t *p_out;
-
-    if( !p_pic )
-        return NULL;
-
-    const video_palette_t *p_yuvp = p_filter->fmt_in.video.p_palette;
-
-    assert( p_yuvp != NULL );
-    assert( p_filter->fmt_in.video.i_chroma == VLC_CODEC_YUVP );
-    assert( p_filter->fmt_in.video.i_width == p_filter->fmt_out.video.i_width );
-    assert( p_filter->fmt_in.video.i_height == p_filter->fmt_out.video.i_height );
-
-    /* Request output picture */
-    p_out = filter_NewPicture( p_filter );
-    if( !p_out )
-    {
-        picture_Release( p_pic );
-        return NULL;
-    }
-
-    if( p_filter->fmt_out.video.i_chroma == VLC_CODEC_YUVA )
-    {
-        for( unsigned int y = 0; y < p_filter->fmt_in.video.i_height; y++ )
-        {
-            const uint8_t *p_line = &p_pic->p->p_pixels[y*p_pic->p->i_pitch];
-            uint8_t *p_y = &p_out->Y_PIXELS[y*p_out->Y_PITCH];
-            uint8_t *p_u = &p_out->U_PIXELS[y*p_out->U_PITCH];
-            uint8_t *p_v = &p_out->V_PIXELS[y*p_out->V_PITCH];
-            uint8_t *p_a = &p_out->A_PIXELS[y*p_out->A_PITCH];
-
-            for( unsigned int x = 0; x < p_filter->fmt_in.video.i_width; x++ )
-            {
-                const int v = p_line[x];
-
-                if( v > p_yuvp->i_entries )  /* maybe assert ? */
-                    continue;
-
-                p_y[x] = p_yuvp->palette[v][0];
-                p_u[x] = p_yuvp->palette[v][1];
-                p_v[x] = p_yuvp->palette[v][2];
-                p_a[x] = p_yuvp->palette[v][3];
-            }
-        }
-    }
-    else if( p_filter->fmt_out.video.i_chroma == VLC_CODEC_RGBA )
-    {
-        video_palette_t rgbp;
-
-        /* Create a RGBA palette */
-        rgbp.i_entries = p_yuvp->i_entries;
-        for( int i = 0; i < p_yuvp->i_entries; i++ )
-        {
-            Yuv2Rgb( &rgbp.palette[i][0], &rgbp.palette[i][1], &rgbp.palette[i][2],
-                     p_yuvp->palette[i][0], p_yuvp->palette[i][1], p_yuvp->palette[i][2] );
-            rgbp.palette[i][3] = p_yuvp->palette[i][3];
-        }
-
-        for( unsigned int y = 0; y < p_filter->fmt_in.video.i_height; y++ )
-        {
-            const uint8_t *p_line = &p_pic->p->p_pixels[y*p_pic->p->i_pitch];
-            uint8_t *p_rgba = &p_out->p->p_pixels[y*p_out->p->i_pitch];
-
-            for( unsigned int x = 0; x < p_filter->fmt_in.video.i_width; x++ )
-            {
-                const int v = p_line[x];
-
-                if( v >= rgbp.i_entries )  /* maybe assert ? */
-                    continue;
-
-                p_rgba[4*x+0] = rgbp.palette[v][0];
-                p_rgba[4*x+1] = rgbp.palette[v][1];
-                p_rgba[4*x+2] = rgbp.palette[v][2];
-                p_rgba[4*x+3] = rgbp.palette[v][3];
-            }
-        }
-    }
-    else
-    {
-        video_palette_t rgbp;
-
-        assert( p_filter->fmt_out.video.i_chroma == VLC_CODEC_ARGB );
-        /* Create a RGBA palette */
-        rgbp.i_entries = p_yuvp->i_entries;
-        for( int i = 0; i < p_yuvp->i_entries; i++ )
-        {
-            Yuv2Rgb( &rgbp.palette[i][1], &rgbp.palette[i][2], &rgbp.palette[i][3],
-                     p_yuvp->palette[i][0], p_yuvp->palette[i][1], p_yuvp->palette[i][2] );
-            rgbp.palette[i][0] = p_yuvp->palette[i][3];
-        }
-
-        for( unsigned int y = 0; y < p_filter->fmt_in.video.i_height; y++ )
-        {
-            const uint8_t *p_line = &p_pic->p->p_pixels[y*p_pic->p->i_pitch];
-            uint8_t *p_rgba = &p_out->p->p_pixels[y*p_out->p->i_pitch];
-
-            for( unsigned int x = 0; x < p_filter->fmt_in.video.i_width; x++ )
-            {
-                const int v = p_line[x];
-
-                if( v >= rgbp.i_entries )  /* maybe assert ? */
-                    continue;
-
-                p_rgba[4*x+0] = rgbp.palette[v][0];
-                p_rgba[4*x+1] = rgbp.palette[v][1];
-                p_rgba[4*x+2] = rgbp.palette[v][2];
-                p_rgba[4*x+3] = rgbp.palette[v][3];
-            }
-        }
-
-    }
-
-    picture_CopyProperties( p_out, p_pic );
-    picture_Release( p_pic );
-    return p_out;
-}
-
-/* FIXME copied from blend.c */
-static inline uint8_t vlc_uint8( int v )
-{
-    if( v > 255 )
-        return 255;
-    else if( v < 0 )
-        return 0;
-    return v;
-}
-static void Yuv2Rgb( uint8_t *r, uint8_t *g, uint8_t *b, int y1, int u1, int v1 )
-{
-    /* macros used for YUV pixel conversions */
-#   define SCALEBITS 10
-#   define ONE_HALF  (1 << (SCALEBITS - 1))
-#   define FIX(x)    ((int) ((x) * (1<<SCALEBITS) + 0.5))
-
-    int y, cb, cr, r_add, g_add, b_add;
-
-    cb = u1 - 128;
-    cr = v1 - 128;
-    r_add = FIX(1.40200*255.0/224.0) * cr + ONE_HALF;
-    g_add = - FIX(0.34414*255.0/224.0) * cb
-            - FIX(0.71414*255.0/224.0) * cr + ONE_HALF;
-    b_add = FIX(1.77200*255.0/224.0) * cb + ONE_HALF;
-    y = (y1 - 16) * FIX(255.0/219.0);
-    *r = vlc_uint8( (y + r_add) >> SCALEBITS );
-    *g = vlc_uint8( (y + g_add) >> SCALEBITS );
-    *b = vlc_uint8( (y + b_add) >> SCALEBITS );
-#undef FIX
-}
index 3828449..fef597f 100644 (file)
@@ -1080,6 +1080,7 @@ modules/video_chroma/i422_yuy2.h
 modules/video_chroma/omxdl.c
 modules/video_chroma/rv32.c
 modules/video_chroma/swscale.c
+modules/video_chroma/yuvp.c
 modules/video_chroma/yuy2_i420.c
 modules/video_chroma/yuy2_i422.c
 modules/video_filter/adjust.c
@@ -1144,7 +1145,6 @@ modules/video_filter/subsdelay.c
 modules/video_filter/transform.c
 modules/video_filter/vhs.c
 modules/video_filter/wave.c
-modules/video_filter/yuvp.c
 modules/video_output/aa.c
 modules/video_output/android/android_window.c
 modules/video_output/android/nativewindow.c