[vlc-devel] karaoke filter

郭宇宏 yuhong.guo68 at gmail.com
Sat Apr 9 14:26:35 CEST 2011


I'm VideoLan gsoc 2011 student yuhong.

This is the filter porting from Mplayer.

/*****************************************************************************
 * karaoke.c: karaoke filter
 *****************************************************************************
 * Copyright (C) 2011 the VideoLAN team
 * $Id: 6a9dc2700bb1c0026a663a834b66666666666 $
 *
 * Edit By YuHong
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 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 General Public License for more details.
 *
 * You should have received a copy of the GNU 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_aout.h>
#include <vlc_filter.h>

/*****************************************************************************
 * Local prototypes
 *****************************************************************************/

static int  Open     ( vlc_object_t * );
static void Close    ( vlc_object_t * );
static void *DoWork( filter_t *, block_t * );

/*****************************************************************************
 * Module descriptor
 *****************************************************************************/
vlc_module_begin ()
    set_description( N_("karaoke audio filter") )
    set_shortname( N_("karaoke af") )
    set_category( CAT_AUDIO )
    add_shortcut( "karaoke" )
    set_capability( "audio filter", 0 )
    set_callbacks( Open, Close )
vlc_module_end ()

/*****************************************************************************
 * Open: initialize and create stuff
 *****************************************************************************/
static int Open( vlc_object_t *p_this )
{
    filter_t *p_filter = (filter_t*)p_this;
    p_filter->pf_audio_filter = DoWork;

    return VLC_SUCCESS;
}

/*****************************************************************************
 * DoWork : Do karaoke filter
 *****************************************************************************/
static void *DoWork( filter_t *p_filter, block_t *p_in_buf )
{
    int i, i_chan;
    int i_samples = p_in_buf->i_nb_samples;
    int i_channels = aout_FormatNbChannels( &p_filter->fmt_in.audio );

    /* filter calculation */
    for( i = 0; i < i_samples; i++) {
        for( i_chan = 0; i_chan < i_channels; i_chan++ ) {
           p_in_buf[i] = (p_in_buf[i] - p_in_buf[i+1]) * 0.7;
           p_in_buf[i+1] = p_in_buf[i];
        }
    }

}

/**********************************************************************
 * Close
 **********************************************************************/
static void Close( vlc_object_t *p_this )
{
    filter_t *p_filter = (filter_t*)p_this;
    free(p_filter);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20110409/625b33b9/attachment.html>


More information about the vlc-devel mailing list