X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fvideo_filter%2Fscale.c;h=08842995a929dfc5319a05ff4f52cc51ae6ff227;hb=c9fb696cf17a2dda3850e2e40ac4f3f057905ee7;hp=e2c3da8b3a57dc8dd589b75e579f8b2b1a9947dc;hpb=51bbf793131496c6f31f70953ff434f17be80d63;p=vlc diff --git a/modules/video_filter/scale.c b/modules/video_filter/scale.c index e2c3da8b3a..08842995a9 100644 --- a/modules/video_filter/scale.c +++ b/modules/video_filter/scale.c @@ -1,26 +1,26 @@ /***************************************************************************** - * resize.c: video scaling module for YUVP/A, I420 and RGBA pictures + * scale.c: video scaling module for YUVP/A, I420 and RGBA pictures * Uses the low quality "nearest neighbour" algorithm. ***************************************************************************** - * Copyright (C) 2003-2007 the VideoLAN team + * Copyright (C) 2003-2007 VLC authors and VideoLAN * $Id$ * * Authors: Gildas Bazin * Antoine Cellerier * - * 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. *****************************************************************************/ /***************************************************************************** @@ -32,23 +32,12 @@ #include #include -#include "vlc_filter.h" - -/***************************************************************************** - * filter_sys_t : filter descriptor - *****************************************************************************/ -struct filter_sys_t -{ - es_format_t fmt_in; - es_format_t fmt_out; -}; +#include /**************************************************************************** * Local prototypes ****************************************************************************/ static int OpenFilter ( vlc_object_t * ); -static void CloseFilter( vlc_object_t * ); - static picture_t *Filter( filter_t *, picture_t * ); /***************************************************************************** @@ -57,7 +46,7 @@ static picture_t *Filter( filter_t *, picture_t * ); vlc_module_begin () set_description( N_("Video scaling filter") ) set_capability( "video filter2", 10 ) - set_callbacks( OpenFilter, CloseFilter ) + set_callbacks( OpenFilter, NULL ) vlc_module_end () /***************************************************************************** @@ -66,24 +55,23 @@ vlc_module_end () static int OpenFilter( vlc_object_t *p_this ) { filter_t *p_filter = (filter_t*)p_this; - filter_sys_t *p_sys; if( ( p_filter->fmt_in.video.i_chroma != VLC_CODEC_YUVP && p_filter->fmt_in.video.i_chroma != VLC_CODEC_YUVA && p_filter->fmt_in.video.i_chroma != VLC_CODEC_I420 && p_filter->fmt_in.video.i_chroma != VLC_CODEC_YV12 && p_filter->fmt_in.video.i_chroma != VLC_CODEC_RGB32 && - p_filter->fmt_in.video.i_chroma != VLC_CODEC_RGBA ) || + p_filter->fmt_in.video.i_chroma != VLC_CODEC_RGBA && + p_filter->fmt_in.video.i_chroma != VLC_CODEC_ARGB ) || p_filter->fmt_in.video.i_chroma != p_filter->fmt_out.video.i_chroma ) { return VLC_EGENERIC; } - /* Allocate the memory needed to store the decoder's structure */ - if( ( p_filter->p_sys = p_sys = - (filter_sys_t *)malloc(sizeof(filter_sys_t)) ) == NULL ) - return VLC_ENOMEM; + if( p_filter->fmt_in.video.orientation != p_filter->fmt_out.video.orientation ) + return VLC_EGENERIC; + video_format_ScaleCropAr( &p_filter->fmt_out.video, &p_filter->fmt_in.video ); p_filter->pf_video_filter = Filter; msg_Dbg( p_filter, "%ix%i -> %ix%i", p_filter->fmt_in.video.i_width, @@ -93,17 +81,6 @@ static int OpenFilter( vlc_object_t *p_this ) return VLC_SUCCESS; } -/***************************************************************************** - * CloseFilter: clean up the filter - *****************************************************************************/ -static void CloseFilter( vlc_object_t *p_this ) -{ - filter_t *p_filter = (filter_t*)p_this; - filter_sys_t *p_sys = p_filter->p_sys; - - free( p_sys ); -} - /**************************************************************************** * Filter: the whole thing ****************************************************************************/ @@ -122,6 +99,8 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) (p_filter->fmt_out.video.i_width == 0) ) return NULL; + video_format_ScaleCropAr( &p_filter->fmt_out.video, &p_filter->fmt_in.video ); + /* Request output picture */ p_pic_dst = filter_NewPicture( p_filter ); if( !p_pic_dst ) @@ -131,6 +110,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) } if( p_filter->fmt_in.video.i_chroma != VLC_CODEC_RGBA && + p_filter->fmt_in.video.i_chroma != VLC_CODEC_ARGB && p_filter->fmt_in.video.i_chroma != VLC_CODEC_RGB32 ) { for( i_plane = 0; i_plane < p_pic_dst->i_planes; i_plane++ )