/*****************************************************************************
* deinterlace.c: ppc deinterlacing functions
*****************************************************************************
* Copyright (C) 2011, 2026 VLC authors and VideoLAN
*
* Author: Sam Hocevar <sam@zoy.org> (generic C routine)
* Eric Petit <eric.petit@lapsus.org> (Altivec)
* Mazen Ewiss <mazenrory@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()
¤ Dauer der Verarbeitung: 0.4 Sekunden
¤
*© Formatika GbR, Deutschland