[vlc-commits] [Git][videolan/vlc][master] 2 commits: deinterlace: extract altivec routine to isa/ppc module
Steve Lhomme (@robUx4)
gitlab at videolan.org
Thu Aug 20 16:21:23 UTC 2026
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
deb68d6f by Mazen Hassan at 2026-08-20T16:05:27+00:00
deinterlace: extract altivec routine to isa/ppc module
- - - - -
c6c50f38 by Mazen Hassan at 2026-08-20T16:05:27+00:00
deinterlace: wire generic merge routines through CPU dispatch
- - - - -
7 changed files:
- modules/Makefile.am
- + modules/isa/ppc/Makefile.am
- + modules/isa/ppc/deinterlace.c
- modules/video_filter/Makefile.am
- modules/video_filter/deinterlace/deinterlace.c
- modules/video_filter/deinterlace/merge.c
- modules/video_filter/deinterlace/merge.h
Changes:
=====================================
modules/Makefile.am
=====================================
@@ -82,6 +82,7 @@ include hw/vdpau/Makefile.am
include hw/mmal/Makefile.am
include isa/aarch64/Makefile.am
include isa/arm/Makefile.am
+include isa/ppc/Makefile.am
include isa/riscv/Makefile.am
include isa/x86/Makefile.am
include keystore/Makefile.am
=====================================
modules/isa/ppc/Makefile.am
=====================================
@@ -0,0 +1,16 @@
+ppcdir = $(pluginsdir)/ppc
+ppc_PLUGINS =
+ppc_LTLIBRARIES =
+if HAVE_PARTIAL_LINKING
+noinst_LTLIBRARIES += $(ppc_PLUGINS)
+else
+ppc_LTLIBRARIES += $(ppc_PLUGINS)
+endif
+
+libdeinterlace_ppc_plugin_la_SOURCES = \
+ isa/ppc/deinterlace.c
+
+if HAVE_ALTIVEC
+ppc_PLUGINS += \
+ libdeinterlace_ppc_plugin.la
+endif
=====================================
modules/isa/ppc/deinterlace.c
=====================================
@@ -0,0 +1,117 @@
+/*****************************************************************************
+ * deinterlace.c: ppc deinterlacing functions
+ *****************************************************************************
+ * Copyright (C) 2011, 2026 VLC authors and VideoLAN
+ *
+ * Author: Sam Hocevar <sam at zoy.org> (generic C routine)
+ * Eric Petit <eric.petit at lapsus.org> (Altivec)
+ * Mazen Ewiss <mazenrory at gmail.com> (moved functions to ppc)
+ * 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.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_cpu.h>
+#include <vlc_plugin.h>
+#include <stdint.h>
+#include "../../video_filter/deinterlace/merge.h"
+
+#if HAVE_ALTIVEC_H
+ #include <altivec.h>
+#endif
+
+VLC_ALTIVEC
+static void MergeAltivec( void *_p_dest, const void *_p_s1,
+ const void *_p_s2, size_t i_bytes )
+{
+ uint8_t *p_dest = _p_dest;
+ const uint8_t *p_s1 = _p_s1;
+ const uint8_t *p_s2 = _p_s2;
+ uint8_t *p_end = p_dest + i_bytes - 15;
+
+ /* Use C until the first 16-bytes aligned destination pixel */
+ while( (uintptr_t)p_dest & 0xF )
+ {
+ *p_dest++ = ( (uint16_t)(*p_s1++) + (uint16_t)(*p_s2++) + 1) >> 1;
+ }
+
+ if( ( (int)p_s1 & 0xF ) | ( (int)p_s2 & 0xF ) )
+ {
+ /* Unaligned source */
+ vector unsigned char s1v, s2v, destv;
+ vector unsigned char s1oldv, s2oldv, s1newv, s2newv;
+ vector unsigned char perm1v, perm2v;
+
+ perm1v = vec_lvsl( 0, p_s1 );
+ perm2v = vec_lvsl( 0, p_s2 );
+ s1oldv = vec_ld( 0, p_s1 );
+ s2oldv = vec_ld( 0, p_s2 );
+
+ while( p_dest < p_end )
+ {
+ s1newv = vec_ld( 16, p_s1 );
+ s2newv = vec_ld( 16, p_s2 );
+ s1v = vec_perm( s1oldv, s1newv, perm1v );
+ s2v = vec_perm( s2oldv, s2newv, perm2v );
+ s1oldv = s1newv;
+ s2oldv = s2newv;
+ destv = vec_avg( s1v, s2v );
+ vec_st( destv, 0, p_dest );
+
+ p_s1 += 16;
+ p_s2 += 16;
+ p_dest += 16;
+ }
+ }
+ else
+ {
+ /* Aligned source */
+ vector unsigned char s1v, s2v, destv;
+
+ while( p_dest < p_end )
+ {
+ s1v = vec_ld( 0, p_s1 );
+ s2v = vec_ld( 0, p_s2 );
+ destv = vec_avg( s1v, s2v );
+ vec_st( destv, 0, p_dest );
+
+ p_s1 += 16;
+ p_s2 += 16;
+ p_dest += 16;
+ }
+ }
+
+ p_end += 15;
+
+ while( p_dest < p_end )
+ *p_dest++ = ( *p_s1++ + *p_s2++ + 1) >> 1;
+}
+
+
+static void Probe(void *data)
+{
+ if (vlc_CPU_ALTIVEC()) {
+ struct deinterlace_functions *const f = data;
+ f->merges[0] = MergeAltivec;
+ }
+}
+
+vlc_module_begin()
+ set_description("PowerPC optimisation for deinterlacing")
+ set_cpu_funcs("deinterlace functions", Probe, 20 )
+vlc_module_end()
=====================================
modules/video_filter/Makefile.am
=====================================
@@ -175,9 +175,7 @@ libdeinterlace_plugin_la_CFLAGS = $(AM_CFLAGS)
if HAVE_X86ASM
libdeinterlace_plugin_la_SOURCES += video_filter/deinterlace/yadif_x86.asm
endif
-if HAVE_ALTIVEC
-libdeinterlace_plugin_la_CPPFLAGS += -DCAN_COMPILE_C_ALTIVEC
-endif
+
libdeinterlace_plugin_la_LIBADD = libdeinterlace_common.la
video_filter_PLUGINS += libdeinterlace_plugin.la
=====================================
modules/video_filter/deinterlace/deinterlace.c
=====================================
@@ -289,6 +289,13 @@ static int Mouse( filter_t *p_filter,
"in the Phosphor framerate doubler. "\
"Default: Low.")
+static void Probe(void *data)
+{
+ struct deinterlace_functions *const funcs = data;
+ funcs->merges[0] = Merge8BitGeneric;
+ funcs->merges[1] = Merge16BitGeneric;
+}
+
vlc_module_begin ()
set_description( N_("Deinterlacing video filter") )
set_shortname( N_("Deinterlace" ))
@@ -307,6 +314,8 @@ vlc_module_begin ()
change_integer_list( phosphor_dimmer_list, phosphor_dimmer_list_text )
change_safe ()
set_deinterlace_callback( Open )
+ add_submodule()
+ set_cpu_funcs("deinterlace functions", Probe, 1)
vlc_module_end ()
/*****************************************************************************
@@ -490,9 +499,7 @@ static const struct vlc_filter_operations filter_ops = {
.close = Close,
};
-static struct deinterlace_functions funcs = {
- { Merge8BitGeneric, Merge16BitGeneric, },
-};
+static struct deinterlace_functions funcs ;
/*****************************************************************************
* Open
@@ -554,11 +561,6 @@ notsupp:
IVTCClearState( p_filter );
-#if defined(CAN_COMPILE_C_ALTIVEC)
- if( pixel_size == 1 && vlc_CPU_ALTIVEC() )
- p_sys->pf_merge = MergeAltivec;
- else
-#endif
{
vlc_CPU_functions_init_once("deinterlace functions", &funcs);
p_sys->pf_merge = funcs.merges[stdc_trailing_zeros(pixel_size)];
=====================================
modules/video_filter/deinterlace/merge.c
=====================================
@@ -30,12 +30,8 @@
#include <stdint.h>
#include <vlc_common.h>
-#include <vlc_cpu.h>
#include "merge.h"
-#ifdef HAVE_ALTIVEC_H
-# include <altivec.h>
-#endif
/*****************************************************************************
* Merge (line blending) routines
@@ -62,72 +58,3 @@ void Merge16BitGeneric( void *_p_dest, const void *_p_s1,
for( size_t i_words = i_bytes / 2; i_words > 0; i_words-- )
*p_dest++ = ( *p_s1++ + *p_s2++ + 1) >> 1;
}
-
-#ifdef CAN_COMPILE_C_ALTIVEC
-VLC_ALTIVEC
-void MergeAltivec( void *_p_dest, const void *_p_s1,
- const void *_p_s2, size_t i_bytes )
-{
- uint8_t *p_dest = _p_dest;
- const uint8_t *p_s1 = _p_s1;
- const uint8_t *p_s2 = _p_s2;
- uint8_t *p_end = p_dest + i_bytes - 15;
-
- /* Use C until the first 16-bytes aligned destination pixel */
- while( (uintptr_t)p_dest & 0xF )
- {
- *p_dest++ = ( (uint16_t)(*p_s1++) + (uint16_t)(*p_s2++) + 1) >> 1;
- }
-
- if( ( (int)p_s1 & 0xF ) | ( (int)p_s2 & 0xF ) )
- {
- /* Unaligned source */
- vector unsigned char s1v, s2v, destv;
- vector unsigned char s1oldv, s2oldv, s1newv, s2newv;
- vector unsigned char perm1v, perm2v;
-
- perm1v = vec_lvsl( 0, p_s1 );
- perm2v = vec_lvsl( 0, p_s2 );
- s1oldv = vec_ld( 0, p_s1 );
- s2oldv = vec_ld( 0, p_s2 );
-
- while( p_dest < p_end )
- {
- s1newv = vec_ld( 16, p_s1 );
- s2newv = vec_ld( 16, p_s2 );
- s1v = vec_perm( s1oldv, s1newv, perm1v );
- s2v = vec_perm( s2oldv, s2newv, perm2v );
- s1oldv = s1newv;
- s2oldv = s2newv;
- destv = vec_avg( s1v, s2v );
- vec_st( destv, 0, p_dest );
-
- p_s1 += 16;
- p_s2 += 16;
- p_dest += 16;
- }
- }
- else
- {
- /* Aligned source */
- vector unsigned char s1v, s2v, destv;
-
- while( p_dest < p_end )
- {
- s1v = vec_ld( 0, p_s1 );
- s2v = vec_ld( 0, p_s2 );
- destv = vec_avg( s1v, s2v );
- vec_st( destv, 0, p_dest );
-
- p_s1 += 16;
- p_s2 += 16;
- p_dest += 16;
- }
- }
-
- p_end += 15;
-
- while( p_dest < p_end )
- *p_dest++ = ( *p_s1++ + *p_s2++ + 1) >> 1;
-}
-#endif
=====================================
modules/video_filter/deinterlace/merge.h
=====================================
@@ -112,16 +112,4 @@ void Merge8BitGeneric( void *_p_dest, const void *_p_s1, const void *_p_s2,
void Merge16BitGeneric( void *_p_dest, const void *_p_s1, const void *_p_s2,
size_t i_bytes );
-#if defined(CAN_COMPILE_C_ALTIVEC)
-/**
- * Altivec routine to blend pixels from two picture lines.
- *
- * @param _p_dest Target
- * @param _p_s1 Source line A
- * @param _p_s2 Source line B
- * @param i_bytes Number of bytes to merge
- */
-void MergeAltivec ( void *, const void *, const void *, size_t );
-#endif
-
#endif
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/453f441b1c730487dd6a6cc9b9d0a08df3e794b1...c6c50f3887b8656206ae3a8ec10268d006f5ab82
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/453f441b1c730487dd6a6cc9b9d0a08df3e794b1...c6c50f3887b8656206ae3a8ec10268d006f5ab82
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help
More information about the vlc-commits
mailing list