X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fvideo_filter%2Finvert.c;h=681c992398a41ebacecedde9d3f1cb21184e32b2;hb=908a51341bfa366f5ec7b650d32e423ae38ac5f0;hp=424ef51f61c13e8600cf5f561aa395b6a64d39e5;hpb=99fab9089e9e1709d9c3a4bc5ced0c137ac59134;p=vlc diff --git a/modules/video_filter/invert.c b/modules/video_filter/invert.c index 424ef51f61..681c992398 100644 --- a/modules/video_filter/invert.c +++ b/modules/video_filter/invert.c @@ -1,24 +1,24 @@ /***************************************************************************** * invert.c : Invert video plugin for vlc ***************************************************************************** - * Copyright (C) 2000-2006 the VideoLAN team + * Copyright (C) 2000-2006 VLC authors and VideoLAN * $Id$ * * Authors: Samuel Hocevar * - * 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 + * 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 General Public License for more details. + * 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 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. + * 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. *****************************************************************************/ /***************************************************************************** @@ -29,10 +29,11 @@ # include "config.h" #endif -#include -#include +#include +#include -#include "vlc_filter.h" +#include +#include "filter_picture.h" /***************************************************************************** * Local prototypes @@ -45,25 +46,15 @@ static picture_t *Filter( filter_t *, picture_t * ); /***************************************************************************** * Module descriptor *****************************************************************************/ -vlc_module_begin(); - set_description( _("Invert video filter") ); - set_shortname( _("Color inversion" )); - set_category( CAT_VIDEO ); - set_subcategory( SUBCAT_VIDEO_VFILTER ); - set_capability( "video filter2", 0 ); - add_shortcut( "invert" ); - set_callbacks( Create, Destroy ); -vlc_module_end(); - -/***************************************************************************** - * vout_sys_t: Invert video output method descriptor - ***************************************************************************** - * This structure is part of the video output thread descriptor. - * It describes the Invert specific properties of an output thread. - *****************************************************************************/ -struct filter_sys_t -{ -}; +vlc_module_begin () + set_description( N_("Invert video filter") ) + set_shortname( N_("Color inversion" )) + set_category( CAT_VIDEO ) + set_subcategory( SUBCAT_VIDEO_VFILTER ) + set_capability( "video filter2", 0 ) + add_shortcut( "invert" ) + set_callbacks( Create, Destroy ) +vlc_module_end () /***************************************************************************** * Create: allocates Invert video thread output method @@ -73,17 +64,19 @@ struct filter_sys_t static int Create( vlc_object_t *p_this ) { filter_t *p_filter = (filter_t *)p_this; + vlc_fourcc_t fourcc = p_filter->fmt_in.video.i_chroma; - /* Allocate structure */ - p_filter->p_sys = malloc( sizeof( filter_sys_t ) ); - if( p_filter->p_sys == NULL ) - { - msg_Err( p_filter, "out of memory" ); - return VLC_ENOMEM; - } + if( fourcc == VLC_CODEC_YUVP || fourcc == VLC_CODEC_RGBP + || fourcc == VLC_CODEC_RGBA ) + return VLC_EGENERIC; - p_filter->pf_video_filter = Filter; + const vlc_chroma_description_t *p_chroma = + vlc_fourcc_GetChromaDescription( fourcc ); + if( p_chroma == NULL + || p_chroma->pixel_size * 8 != p_chroma->pixel_bits ) + return VLC_EGENERIC; + p_filter->pf_video_filter = Filter; return VLC_SUCCESS; } @@ -94,9 +87,7 @@ static int Create( vlc_object_t *p_this ) *****************************************************************************/ static void Destroy( vlc_object_t *p_this ) { - filter_t *p_filter = (filter_t *)p_this; - - free( p_filter->p_sys ); + (void)p_this; } /***************************************************************************** @@ -114,20 +105,19 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) if( !p_pic ) return NULL; - p_outpic = p_filter->pf_vout_buffer_new( p_filter ); + p_outpic = filter_NewPicture( p_filter ); if( !p_outpic ) { msg_Warn( p_filter, "can't get output picture" ); - if( p_pic->pf_release ) - p_pic->pf_release( p_pic ); + picture_Release( p_pic ); return NULL; } - if( p_pic->format.i_chroma == VLC_FOURCC('Y','U','V','A') ) + if( p_pic->format.i_chroma == VLC_CODEC_YUVA ) { /* We don't want to invert the alpha plane */ i_planes = p_pic->i_planes - 1; - p_filter->p_libvlc->pf_memcpy( + memcpy( p_outpic->p[A_PLANE].p_pixels, p_pic->p[A_PLANE].p_pixels, p_pic->p[A_PLANE].i_pitch * p_pic->p[A_PLANE].i_lines ); } @@ -180,14 +170,5 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) } } - p_outpic->date = p_pic->date; - p_outpic->b_force = p_pic->b_force; - p_outpic->i_nb_fields = p_pic->i_nb_fields; - p_outpic->b_progressive = p_pic->b_progressive; - p_outpic->b_top_field_first = p_pic->b_top_field_first; - - if( p_pic->pf_release ) - p_pic->pf_release( p_pic ); - - return p_outpic; + return CopyInfoAndRelease( p_outpic, p_pic ); }